我創建了一個自定義類並分配給uiview ..該視圖在uiviewcontroller中打開..但問題是,從這個自定義視圖導航不起作用....在ios中通過CustomUiview類導航
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.view=[[UIView alloc]initWithFrame:CGRectMake(0, 65, 250, 503)];
self.view.backgroundColor=[UIColor darkGrayColor];
UIView *subView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 100)];
[self.view addSubview:subView];
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0, 99, subView.frame.size.width, 1.0f);
bottomBorder.backgroundColor = [UIColor colorWithWhite:0.8f
alpha:1.0f].CGColor;
[subView.layer addSublayer:bottomBorder];
UIImageView *profimg=[[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 60, 60)];
profimg.backgroundColor=[UIColor redColor];
profimg.layer.cornerRadius=profimg.frame.size.width/2;
profimg.layer.masksToBounds=YES;
UILabel *lbluname=[[UILabel alloc]initWithFrame:CGRectMake(75, 15, 160, 25)];
[email protected]"User Name";
lbluname.font=[UIFont systemFontOfSize:14.0];
[subView addSubview:lbluname];
UILabel *lblEmail=[[UILabel alloc]initWithFrame:CGRectMake(75, 40, 170, 25)];
[email protected]"[email protected]";
lblEmail.font=[UIFont systemFontOfSize:14.0];
[subView addSubview:lblEmail];
UILabel *lblpwdVerify=[[UILabel alloc]initWithFrame:CGRectMake(75, 65, 160, 25)];
[email protected]"Verify your profile";
lblpwdVerify.font=[UIFont systemFontOfSize:14.0];
[subView addSubview:lblpwdVerify];
[subView addSubview:profimg];
UITableView *tbl=[[UITableView alloc]initWithFrame:CGRectMake(0, 100, 250, 400)];
tbl.backgroundColor=[UIColor whiteColor];
tbl.delegate=self;
tbl.dataSource=self;
[self.view addSubview:tbl];
self.bounds=self.view.bounds;
[self addSubview:self.view];
self.view.frame = CGRectMake(-250, 65, 250, 503);
[UIView animateWithDuration:1.0 animations:^{
self.view.frame = CGRectMake(0, 65, 250, 503);
}];
listMenuSide=[[NSMutableArray alloc]initWithObjects:@"Live Radar",@"Online",@"Become a Premium",@"History",@"Message",@"Advance Search",@"Match",@"News",@"Edit Profile",@"Find Me Good",@"I Think Good",@"Sign Out",nil];
listImg=[[NSMutableArray alloc]initWithObjects:@"radar.gif",@"online.png",@"spade.png",@"visitor.png",@"msg.png",@"search.png",@"match.png",@"news.png",@"edit_profile.png",@"like.png",@"findgood.png",@"signoff.png",nil];
self.view.backgroundColor=[UIColor colorWithRed:68/255.0 green:68/255.0 blue:68/255.0 alpha:1];
tbl.backgroundColor=[UIColor colorWithRed:68/255.0 green:68/255.0 blue:68/255.0 alpha:1];
subView.backgroundColor=[UIColor colorWithRed:68/255.0 green:68/255.0 blue:68/255.0 alpha:1];
}
return self;
}
-(IBAction)clknav:(id)sender{
ProfileView *paaa=[[ProfileView alloc]init];
[paaa didSelectRow:0];
NSLog(@"%s", __PRETTY_FUNCTION__);
}
-(id)initWithCoder:(NSCoder *)aDecoder{
self=[super initWithCoder:aDecoder];
if (self) {
}
return self;
}
-(void)ViewCustom:(UIView *)view{
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 58.0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [listMenuSide count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = @"Cell";
SideViewCcellCustom *cell = (SideViewCcellCustom *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"SideViewCcellCustom" owner:self options:nil];
cell=[nib objectAtIndex:0];
}
cell.lightningImageView.animationDuration = 1.0;
cell.lightningImageView.animationRepeatCount = 5; //default is 0, which repeats indefinitely
[cell.lightningImageView startAnimating];
cell.backgroundColor=[UIColor colorWithRed:68/255.0 green:68/255.0 blue:68/255.0 alpha:1];
cell.lightningImageView.image=[UIImage imageNamed:[listImg objectAtIndex:indexPath.row]];
cell.lbltxt.text=[listMenuSide objectAtIndex:indexPath.row];
//cell.textLabel.text=[listMenuSide objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
OGViewController *homeViewController = [[OGViewController alloc] init];
ProfileView *paaa=[[ProfileView alloc]init];
[paaa didSelectRow:0];
// we can't use navigation controller here....
[self.navigationController pushViewController:homeViewController animated:YES];
}
我已經使用自定義導航也..蝙蝠它不是在UIView的工作
你是如何呈現這個視圖控制器?你是否將其推入導航控制器? – Paulw11 2014-11-22 06:58:56
這段代碼是在視圖還是視圖控制器中? self.navigationController是非零嗎? – rdelmar 2014-11-22 07:20:26
這不是視圖控制器。這是Uiview只顯示在傳送類中。 – 2014-11-24 06:17:27