【发布时间】:2014-10-14 16:52:55
【问题描述】:
我有一个 UIView 的子类,现在我需要显示一个视图控制器,但 UIView 没有方法来显示视图控制器。
这是我的问题
谢谢
这是我的 uiview 子类中的一段代码
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if ([tabella isEqualToString:@"Articoli"]) {
NSDictionary *itm=(NSDictionary*)[comanda objectAtIndex:indexPath.row];
Articoli *aboutViewController = [[Articoli alloc] initWithNibName:@"Articoli" bundle:nil];
aboutViewController.modalPresentationStyle = UIModalPresentationFormSheet;
aboutViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
aboutViewController.idarticolo=[itm objectForKey:@"idarticolo"];
CGRect aboutSheetFrame = aboutViewController.view.frame;
UIViewController *viewController = [UIViewController new];
viewController.view = self;
//here xcode give me a red error
[self presentViewController:viewController animated:YES completion:nil] ;
aboutSheetFrame =CGRectZero;
aboutViewController.view.superview.bounds = aboutSheetFrame;
}
}
【问题讨论】:
-
请分享一段代码...
-
问题是我不知道从 uiview 子类显示视图控制器。
-
这不是一个新问题。看看这个链接。 stackoverflow.com/questions/15779485/…