Gla*_*ing 6 iphone xcode modalviewcontroller
我有一个基于导航的应用程序,它有一个详细视图(UIWebView),在UIToolbar的底部有操作按钮.我想在按下"音符"按钮时添加"音符".当webview处于纵向模式时,一切正常.我按下音符按钮,模态视图打开很好,效果很好.
当webview处于横向模式时,会出现此问题.如果我按下音符按钮,所有打开模态视图的代码都会被调用,但我得到的只是一个白色屏幕.一条评论:如果我以纵向打开模态视图然后旋转设备,它会精细旋转到横向模式.它只是无法在横向模式下正确打开.
我有另一个按钮,它会调出具有相同行为的邮件编辑器.这是我的UIWebViewController中的代码:
- (IBAction)addNotes:(id)sender
{
NotesViewController *notesViewController;
// create the view controller and set it as the root view of a new navigation
// controller
notesViewController = [[NotesViewController alloc] initWithPrimaryKey:self.record.primaryKey];
UINavigationController *newNavigationController =
[[UINavigationController alloc] initWithRootViewController:notesViewController];
// present the navigation controller modally
[self presentModalViewController:newNavigationController animated:YES];
[notesViewController release];
[self.view setNeedsDisplay]; // not sure if I need this! I was trying different things...
[self.devotionText setNeedsDisplay]; // ditto...
[newNavigationController release];
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我尝试过各种不同的东西都无济于事.我只是得到一个没有导航栏的白色屏幕(尽管顶部有一个状态栏).
模态并不总是获得有关旋转的信息,并且它们从状态栏获取信息,这并不总是正常工作.把它放在你的viewWillAppear中修复:[UIApplication sharedApplication].statusBarOrientation = self.interfaceOrientation而且,如果你想在模态中使用导航控制器,你需要创建一个.
此外,您不需要setNeedsDisplay.这只会影响当前的视图,而不会影响您呈现的模态.
Ste*_*ani -1
您不需要新的导航控制器。
- (IBAction)addNotes:(id)sender {
NotesViewController *notesViewController;
// create the view controller and set it as the root view of a new navigation
// controller
notesViewController = [[NotesViewController alloc] initWithPrimaryKey:self.record.primaryKey];
[self.navigationController pushViewController: notesViewController animated: YES];
[notesViewController release];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8511 次 |
| 最近记录: |