ios知识整理

本文详细介绍了iOS和Android应用开发中用户界面交互、数据存储及数据展示的关键技术,包括界面跳转、数据获取、对话框弹出、用户名存储等核心功能。同时,展示了如何在界面中加入返回按钮实现导航功能,以及如何使用弹出对话框进行提示操作。通过调整数据展示方式,优化了用户体验,确保了信息的有效传递。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.跳转界面

//            jrspxsViewController *jrspxsVC=[[jrspxsViewController alloc] initWithNibName:@"jrspxsViewController" bundle:nil];

//            [self presentViewController:jrspxsVC animated:YES completion:nil];

//            [jrspxsVC release];

            

            //存储用户名

            NSUserDefaults *user=[NSUserDefaultsstandardUserDefaults];

            [usersetValue:qqTextforKey:@"UserName"];

            indexViewController *indexVC=[[indexViewControlleralloc]initWithNibName:@"indexViewController"bundle:nil];

            //返回上一个界面

            UINavigationController *nav=[[UINavigationControlleralloc]initWithRootViewController:indexVC];

            

            [selfpresentViewController:nav animated:YES completion:nil];

            [indexVCrelease];

            [navrelease];

2.


- (void)viewDidLoad

{

    [superviewDidLoad];

    //添加back按钮返回上一个界面

    UIBarButtonItem *leftbtn=[[UIBarButtonItemalloc]initWithTitle:@"back"style:UIBarButtonItemStyleBorderedtarget:selfaction:@selector(buttonBack)];

    self.navigationItem.leftBarButtonItem=leftbtn;

    [leftbtnrelease];

}

-(void)buttonBack{

    [selfdismissViewControllerAnimated:YEScompletion:nil];

}

3.弹出对话框

UIAlertView *alter=[[UIAlertViewalloc]initWithTitle:@"登陆成功" message:@"" delegate:nilcancelButtonTitle:nilotherButtonTitles:@"确定登陆",nil];

            [alter show];

            [alter release];

4.取用户名和空出一行Label

之前:

- (void)viewDidLoad

{

    [superviewDidLoad];

    self.tableView=[[UITableViewalloc]  initWithFrame:self.view.bounds];

    self.tableView.dataSource=self;

    self.tableView.delegate=self;

    [self.view addSubview:self.tableView];

之后:

- (void)viewDidLoad

{

   // NSString *pwdText = _pwd.text;

    [superviewDidLoad];

    NSUserDefaults *user=[NSUserDefaultsstandardUserDefaults];

    NSString *name=[user objectForKey:@"UserName"];

//距离顶部有30的距离

    self.tableView=[[UITableViewalloc]  initWithFrame:CGRectMake(0,30,self.view.bounds.size.width,self.view.bounds.size.height-30)];

    self.tableView.dataSource=self;

    self.tableView.delegate=self;

    [self.view addSubview:self.tableView];

5.取数据

之前显示一行:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellIdentifier=@"cellIdentifier";

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell==nil) {

        cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier]autorelease];

    }

    NSDictionary *dic=[self.listDataobjectAtIndex:indexPath.row];

    cell.textLabel.text=[dicobjectForKey:@"dept"];

    return cell;

}

之后显示二行:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellIdentifier=@"cellIdentifier";

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell==nil) {

        cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleValue1reuseIdentifier:cellIdentifier]autorelease];

    }

    NSDictionary *dic=[self.listDataobjectAtIndex:indexPath.row];

    cell.textLabel.text=[dicobjectForKey:@"fd"];

    cell.detailTextLabel.text=[dicobjectForKey:@"ssj"];

    return cell;

}

-------------------------------------------------------------------------------------------------------------------------------------------

//- (void)login {

//    NSString *qqText = _qq.text;

//    NSString *pwdText = _pwd.text;

//    

//    NSLog(@"QQ=%@,密码=%@", qqText, pwdText);

//    [self.view endEditing:YES];// 如果第一响应者存在于self.view里面,就可以退出键盘

//    //传递参数

//    NSMutableArray *params=[NSMutableArray array];

//    //[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"pass",@"dm", nil]];

//    //[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"lfxpass2010",@"pwd", nil]];

//    //设置传递对象

//    ServiceArgs *args=[[[ServiceArgs alloc] init] autorelease];

//    

//    args.methodName=@"selectJjtz";

//    

//    args.soapParams=params;

//    

//    //调用

//    

//    [[ServiceHelper sharedInstance] asynService:args completed:^(NSString *xml, NSDictionary *userInfo) {

//        NSLog(@"xml=%@\n",xml);

//    } failed:^(NSError *error, NSDictionary *userInfo) {

//        NSLog(@"error=%@\n",[error description]);

//    }];

//}



觉得写得不错,帮忙打赏下,谢谢!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值