专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构
Modal出撰写相关控制器
- 创建
写说说
控制器CZMoodViewController
- 创建
传照片
控制器CZPhotoViewController
- 创建
写日志
控制器CZBlogViewController
在
CZMenuViewController
的clickComposeButton:
方法里面创建对应的控制器并modal
出来/// modal出对应的控制器 - (void)clickComposeButton:(CZMenuButton *)button { Class cls = NSClassFromString(button.menuItem.detailVCClassName); UIViewController *vc = [[cls alloc] init]; [self presentViewController:vc animated:YES completion:nil]; }
运行,发现缺少导航栏.需要包装一个导航栏
/// modal出对应的控制器 - (void)clickComposeButton:(CZMenuButton *)button { Class cls = NSClassFromString(button.menuItem.detailVCClassName); // 创建按钮对应的控制器 UIViewController *vc = [[cls alloc] init]; // 包装导航栏 UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; // modal出控制器 [self presentViewController:nav animated:YES completion:nil]; }
运行,
modal
出来的控制器是全屏的,设置modal样式
/// modal出对应的控制器 - (void)clickComposeButton:(CZMenuButton *)button { Class cls = NSClassFromString(button.menuItem.detailVCClassName); // 创建按钮对应的控制器 UIViewController *vc = [[cls alloc] init]; // 包装导航栏 UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; nav.modalPresentationStyle = UIModalPresentationFormSheet; // modal出控制器 [self presentViewController:nav animated:YES completion:nil]; }