Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

objective c - iOS 7 UIToolBar Overriding With Status Bar

I have upgraded my project from iOS 6 to iOS 7 but there seems a little problem. The status bar and a tool bar is overriding and very close to each other. The tool bar was earlier added by manually dragging it in the storyboard. This is how its showing up:

toolbar

I have seen a few questions that are suggesting to use "positionForBar:" and "- (UIBarPosition)positionForBar:(id)bar" but i don't know exactly how to use them, a little explanation and easy way to do it might help. Thanks!

UPDATE: Following is some code that also needs a fix. It was working fine earlier but since the detailviewcontroller (WebViewController) is now embeded inside a navigation controller, the below code is causing an exception. Looks like i need to modify the first line in this method.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

        WebViewController *wvc = [self.navigationController.parentViewController childViewControllers][1];
        RSSItem *entry = [[channel items] objectAtIndex:[indexPath row]];
        wvc.title = entry.title;
        wvc.urlString = entry.link;   
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
_toolBar.delegate = self;

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
    CGRect frame = _toolBar.frame;
    frame.origin = CGPointMake(0, [UIApplication sharedApplication].statusBarFrame.size.height);
    _toolBar.frame = frame;

    return UIBarPositionTopAttached;
}

portrait bar

landscape bar


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...