我是这样推的UIViewController:
UIViewController* individualsController = [[[UIViewController alloc] initWithNibName:@"IndividualsController" bundle:nil] autorelease];
[self.navigationController pushViewController:individualsController animated:YES];
Run Code Online (Sandbox Code Playgroud)
NIB本身正在加载正常,所有元素都加载到屏幕上.但是没有一个视图控制器的方法被调用.没有viewDidLoad,没有viewWillAppear,只是推送NIB而没有别的.
视图插座设置在NIB中; 我无法弄清楚为什么没有人被召唤!
iphone objective-c interface-builder uiviewcontroller pushviewcontroller
在我的窗口基础应用程序中,我需要从我的appdelegate导航到editorview,当我点击我的tabbarcontroller的第二项时,它将显示一个带有三个选项的动作表.
actionsheet工作正常,如果从tabbar中选择第二项,它将显示一个操作表.
但是当我选择行动表的第一个选项时,我需要推送到另一个视图
我在appdelegate中声明我的动作表.
我已经实现了actionsheetdelegate
该方法是trigerred,它可以显示我是否做nslog.但它无法推送到我想要的viewcontroller ..这是我的代码:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
DetailViewController *v2 = [[DetailViewController alloc] init];
NSLog(@"PUSH TRIGER");
[self.window.rootViewController.navigationController pushViewController:v2 animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
注意:我已经在我的故事板中嵌入了tabbarcontroller和导航控制器
我开始更频繁地使用故事板,但我遇到了一个问题.通常当您使用UINavigationController推送视图控制器时,您可以通过以下方式执行此操作,并且您可以将数据与其一起传递:
UIViewController *vc = [[UIViewController alloc] init];
vc.link = [self link];
vc.name = [self name];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]
[nav presentViewController:vc completion:nil animated:YES];
Run Code Online (Sandbox Code Playgroud)
(我做了上面的内存代码,所以它可能不是100%正确).
既然我正在使用storyboard,我自己也没有实例化视图控制器,那么如何用它传递数据呢?谢谢!
storyboard uiviewcontroller uinavigationcontroller pushviewcontroller ios
我有一个UITableiew列出了许多联系人,并从表视图委托didSelectRowAtIndexPath我通过使用UINavigationController pushviewcontroller导航到'Contactview'UIViewController .
例如,如果我将第一个联系人导航到Contactview,则Live Bytes内存从1 MB增加到3 MB.然后,当我点击后退按钮时,会调用viewcontroller delloc方法,但内存仍然保持在2.95MB到3MB左右.我的问题是,当调用viewcontroller delloc方法时,viewcontoller 的内存应该被释放吗?我错了吗?如果我错了,请建议我.我正在使用ARC项目.
提前致谢..
memory-management objective-c uinavigationcontroller pushviewcontroller ios
我想用代码推入另一个视图控制器
[self pushControllerWithName:@"secondeviewcontroller" context:@"Hello"];
Run Code Online (Sandbox Code Playgroud)
它的工作非常适合推动而非 解散
在secondviewcontroller中不起作用
[self dismissController];
Run Code Online (Sandbox Code Playgroud) 我有一个TableViewController,一个SearchResultsController和一个WebViewController.当我单击TableViewController中的一个单元格时,它会推动WebViewController打开一个与单元格相关的URL.
TableViewController有一个UISearchController,它将结果过滤到SearchResultsController中,但是当在SearchResultsController中单击一个单元格时,WebViewController不会被推送.
以下是SearchResultsController的didSelectRowAtIndexPath的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
WebViewController *webViewController = [[WebViewController alloc] init];
NSString *extensionURL = (self.searchResults[indexPath.row])[@"url"];
NSURL *baseURL = [NSURL URLWithString:@"http://www.baseurl.com"];
NSURL *URL = [NSURL URLWithString:extensionURL relativeToURL:baseURL];
webViewController.title = (self.searchResults[indexPath.row])[@"title"];
NSLog(@"%@", URL);
webViewController.URL = URL;
[self.navigationController pushViewController:webViewController
animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我包含了NSLog,看看当单击一个单元格时是否发生了什么,它确实在控制台中显示了url.这让我觉得问题出在navigationController上.
在线查看似乎应该将UISearchController包装在UISearchContainerViewController中,然后将其放入navigationController中.我还是应用程序开发的新手,无法弄清楚如何或在何处执行此操作.
我在我的TableViewController的viewDidLoad中调用我的SearchResultsController,如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
SearchResultsViewController *controller = [[SearchResultsViewController alloc] initWithStyle:UITableViewStylePlain];
[self addObserver:controller forKeyPath:@"results" options:NSKeyValueObservingOptionNew context:nil];
self.searchController = [[UISearchController alloc] initWithSearchResultsController: controller];
self.searchController.searchResultsUpdater = self;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.delegate = self;
self.definesPresentationContext …Run Code Online (Sandbox Code Playgroud) objective-c uinavigationcontroller pushviewcontroller ios uisearchcontroller
我有一个tableview,并且我想在点击行之一时转到另一个vc。我的didSelectRowAtIndexPath函数如下。print命令有效,并显示右键单击的行。但是当我使用self.navigationController?.pushViewController时,它不会通过playVideo storyBoardId进入vc。将其更改为presentViewController后,它可以工作。我的代码有什么问题,推送不起作用?
谢谢
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("clicked " + String(indexPath.row) )
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("playVideo") as! PlayVideoViewController
vc.id = self.video[indexPath.row].id
// Present View as Modal
//presentViewController(vc as UIViewController, animated: true, completion: nil)
// Push View
//self.navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud) 我的情况如下:
1)我有带有navigationController的rootViewController并在工具栏中添加按钮.当我按下我使用pushViewController方法推送另一个视图.这个视图叫做chooseTypeView,它只有两个单元格的tableview.
2)当点击任何单元格时,将使用相同的方法推送第三个视图以输入一些数据.
3)现在我想按下键盘上的"完成"按钮导航回rootView控制器并关闭当前步骤和根视图之间的所有视图.
我正在使用@Protocol连接视图,我可以将信息从最后一个视图传递到根视图,但我无法忽略它.
谢谢大家,我希望我能说清楚.
这是我的代码......
- (void) threadStartAnimating {
[activityIndicator startAnimating];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
activityIndicator=[[UIActivityIndicatorView alloc] init];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center=[self tableView].center;
[[self tableView] addSubview:activityIndicator];
[NSThread detachNewThreadSelector:@selector(threadStartAnimating) toTarget:self withObject:nil];
EventController *eventController = [[EventController alloc] init];
[eventController setEventID:[[lineItems objectAtIndex:[indexPath row]] objectForKey:@"view_event_button_param"]];
[activityIndicator stopAnimating];
[[self navigationController] pushViewController:eventController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
事件控制器包含一个需要几秒钟才能加载的Web服务.我可以让活动指示器显示的唯一方法是,如果我在那里抛出一个无限循环......我发现了一些例子,提到将它放在一个单独的线程中,但它似乎不起作用.
xcode web-services uiactivityindicatorview pushviewcontroller ios
我写了下面这段代码:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
GameViewController *gameViewController = [[GameViewController alloc]initWithLevelNumber:([levelGroup intValue]*100+indexPath.row) Bonus:NO];
NSLog(@"Retain Counter =%d",gameViewController.retainCount);
[navController pushViewController:gameViewController animated:YES];
[gameViewController release];
NSLog(@"Retain Counter=%d",gameViewController.retainCount);
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
两个日志的结果按顺序1和6!这怎么可能?我只调用一次alloc方法并在将控制器推到堆栈后释放.. alloc-> + 1,push-> + 1,release-> -1 = 1或不?
当我将它从堆栈中弹出时,我希望视图控制器是dealloc'd ..
objective-c uinavigationcontroller pushviewcontroller ios retaincount
通常我们总是使用以下方法从一个视图推送到另一个视图:
[self.navigationController pushViewController:nextView animated:YES];
for some other animations we used :UIViewAnimationTransitionCurlDown / flipRight etc etc..
所有这些都经常使用,
但我希望我的应用程序具有不同的转换 ..
过渡中的任何其他自定义过渡/特殊效果..(推/弹出)或动画的任何其他外部api ..
iphone objective-c uinavigationcontroller pushviewcontroller
使用UITableviewcell类来显示表格列表的单元格。我想使用“ navigationController?.pushViewController”从一个屏幕重定向到另一个屏幕,但它在表格单元格类中不支持。那么我如何UIViewcontroller使用pushViewController从表格单元格移动。
我的代码是:
class TableCell: UITableViewCell
{
let storyBoard : UIStoryboard = UIStoryboard(name: "SubMain", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "DetailReport") as! DetailReport
nextViewController.aryOfResultList = aryForCreateJSONResult
cell.inputViewController?.navigationController?.pushViewController(nextViewController, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。请给我解决我的问题
uitableview uinavigationcontroller pushviewcontroller ios swift
ios ×9
objective-c ×5
iphone ×2
swift ×2
appdelegate ×1
apple-watch ×1
retaincount ×1
storyboard ×1
uitableview ×1
uiview ×1
watchkit ×1
web-services ×1
xcode ×1