|
|
|
IOS - IPAD Split view textfield ไม่อัพเดท แต่ส่งค่าจาก master ไป detail ปกติ |
|
|
|
|
|
|
|
Capture ภาพ พร้อม Code คร่าว ๆ มาดูหน่อยครับ
|
|
|
|
|
Date :
2013-11-01 17:33:13 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserDetailViewController.h
Code (Objective-C)
#import <UIKit/UIKit.h>
#import <sqlite3.h>
@interface UserDetailViewController : UIViewController<UISplitViewControllerDelegate>
{
sqlite3 *database;
IBOutlet UITextField *txtName;
}
@property (strong, nonatomic) id userid;
- (IBAction)BtnPriv;
@end
UserDetailViewController.m
Code (Objective-C)
#import "UserDetailViewController.h"
@interface UserDetailViewController ()
@end
@implementation UserDetailViewController
@synthesize userid;
NSString *uname;
NSString *pswd;
NSString *name;
NSString *utet;
NSString *uaddr;
NSString *umail;
NSString *upos;
NSString *urol;
NSString *uidset;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)setUserid :(id)newuserid
{
if (userid != newuserid) {
userid = newuserid;
uidset = userid;
}
[self loadDataUserid];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadDataUserid];
}
- (void)loadDataUserid
{
NSLog(@"ddd");
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"testDB.sqlite"];
const char *dbpath = [path UTF8String];
if(sqlite3_open(dbpath,&database)!=SQLITE_OK)
{
NSLog(@"Not have DB");
return;
};
const char *uid;
if (self.userid) {
uid = [uidset UTF8String];
}else{
uid = "125204";
}
NSLog(@"%s",uid);
sqlite3_stmt *statement;
sqlite3_prepare_v2(database, "SELECT * From allUser where user_id = ?", -1, &statement, nil);
sqlite3_bind_text(statement, 1,uid, -1, SQLITE_TRANSIENT);
while(sqlite3_step(statement) == SQLITE_ROW) {
name = [[NSString alloc] initWithUTF8String: (char *)sqlite3_column_text(statement, 3)];
}
txtName.text = name;
NSLog(@"%@",txtName);// เมื่อกดtable ใน master แล้วมีค่าเป็น Null????
sqlite3_finalize(statement);
sqlite3_close(database);
}
ShowUserViewController.h
Code (Objective-C)
#import <UIKit/UIKit.h>
#import <sqlite3.h>
@class UserDetailViewController;
@interface ShowUserViewController : UITableViewController
{
NSString *name;
NSString *userid;
}
@property (strong, nonatomic) UserDetailViewController *userdetailViewController;
@end
ShowUserViewController.m
Code (Objective-C)
#import "ShowUserViewController.h"
#import "UserDetailViewController.h"
@interface ShowUserViewController ()
@end
@implementation ShowUserViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
name = @"user_name";
userid = @"user_id";
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
[self loadDataComid];
[self loadDataAllUServiaWebService];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return Users.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
}
NSDictionary *tmpDict = Users[indexPath.row];
cell.textLabel.text = [tmpDict objectForKey:name];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *tmpDict = Users[indexPath.row];
UserDetailViewController *udv = [[UserDetailViewController alloc]init];
[udv setUserid :[tmpDict objectForKey:userid ]];
}
@end
|
|
|
|
|
Date :
2013-11-02 09:39:25 |
By :
NOMAC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|