我是iPhone編程的新手。以前的觀點沒有反應當touchUpInside後退按鈕與[self.view removeFromSuperview]
基本上我有一個MFSideMenuViewController設置viewController作爲rightSideViewController。
設置視圖控制器是UITableView的,當我在tableview中的任意索引挖掘其加載另一個VC爲[rootViewController.view addSubView:VC];
與實現後退按鈕的代碼 - [self.view removeFromSuperview];
到現在爲止它的做工精細
SettingsVC.h
//UITableView Delegate method
if(indexPath.row==1){
VC=[[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"vcStoryBoardIdentifier"];
[VC.view setFrame:[[APP_DELEGATE window] frame]];
[[[[APP_DELEGATE window] rootViewController] view] addSubview:VC.view];
}
在這個VC我有一個實現代碼如下。當我在任何index path.row
點擊它加載另一個VC命名anotherVC作爲子視圖VC [VC.view addSubView:anotherVC];
VC.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTblPS) name:@"VCTblReload" object:nil];
}
-(void)reloadTblPS{
[VCTableView reloadData];
}
//UITableview DataSource method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if(indexPath.row == 0)
{
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:img1 forState:UIControlStateNormal];
[button setImage:img2 forState:UIControlStateHighlighted];
[button setFrame:CGRectMake(220,10,60,20)];
[button addTarget:self action:@selector(openAnotherVc:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];
}
}
return cell;
}
-(void)openAnotherVc:(id)sender{
anotherVC = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"anotherVCStoryBoardID"];
[[anotherVC view] setFrame:[[APP_DELEGATE window] frame]];
[self.view addSubview:[anotherVC view]];
}
-(IBAction)VCcancelBtn:(id)sender{
[self.view removeFromSuperview];
//working fine
}
此anotherVC還含有`一個取消按鈕[anotherVC.view removeFromSuperView];
anotherVC.m
-(IBAction)anotherVCcancelBtn:(id)sender{
[self.view removeFromSuperView];
[[NSNotificationCenter defaultCenter] postNotificationName:@"VCTblReload" object:nil];
}
我的問題是2這裏 1.當我點擊取消anotherVC的按鈕,它是將VC屏幕,但VC沒有響應 2.目前在VC中的tableView甚至不重裝我已經使用的通知和[tableView reloadData];
它將與解釋你的答案是偉大謝謝
您可以發佈您的代碼。不完全得到你的問題。 – Lion