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]);
// }];
//}
觉得写得不错,帮忙打赏下,谢谢!
本文详细介绍了iOS和Android应用开发中用户界面交互、数据存储及数据展示的关键技术,包括界面跳转、数据获取、对话框弹出、用户名存储等核心功能。同时,展示了如何在界面中加入返回按钮实现导航功能,以及如何使用弹出对话框进行提示操作。通过调整数据展示方式,优化了用户体验,确保了信息的有效传递。
614





