数据库数据库.H
#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "DetailtableviewViewController.h"
@interface DBDatabase : NSObject
{
NSString *databasePath;
}
+(DBDatabase*)getSharedInstance;
- (BOOL)createDB;
- (BOOL) saveData:(NSString*)name email:(NSString *)email
password:(NSString *)password confirmpassword:
(NSString*)confirmpassword
age:(NSString*)age department:(NSString*)department;
- (NSArray*) findingEmailid:(NSString*)Emailid password:
(NSString*)password;
- (NSArray*)studentdetailbyTableview:(NSString*)email;
@end
数据库数据库.M
#import "DBDatabase.h"
static DBDatabase *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBDatabase
+(DBDatabase*)getSharedInstance{
if (!sharedInstance) {
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
// Build the path to the database file
databasePath = [[NSString alloc] initWithString:[docsDir
stringByAppendingPathComponent: @"sasi.db"]];
NSLog(@"CREATED DB PATH :%@", databasePath);
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath: databasePath ] == NO)
{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
char *errMsg;
const char *sql_stmt ="CREATE TABLE IF NOT EXISTS USERDETAILS
(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, EMAIL TEXT,
PASSWORD TEXT, CONFIRMPASSWORD TEXT, AGE TEXT, DEPARTMENT
TEXT)";
if (sqlite3_exec(database, sql_stmt, NULL, NULL, &errMsg)
!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"Failed to create table");
}
sqlite3_close(database);
return isSuccess;
}
else {
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}
return isSuccess;
}
-(BOOL) saveData:(NSString*)name email:(NSString *)email password:
(NSString *)password confirmpassword:(NSString *)confirmpassword
age:(NSString*)age department:(NSString*)department;
{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSString *insertSQL = [NSString stringWithFormat:
@"INSERT INTO USERDETAILS (name, email,
password,confirmpassword,age,department) VALUES (\"%@\", \"%@\",
\"%@\",\"%@\", \"%@\",
\"%@\")",name,email,password,confirmpassword,age,department ];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(database, insert_stmt,-1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else {
return NO;
}
//sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findingEmailid:(NSString*)Emailid password:
(NSString*)password;
{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSString *selectSql = [NSString stringWithFormat:
@"SELECT *from USERDETAILS Where email
=\"%@\" and password =\"%@\"",Emailid,password];
NSLog(@"------>%@",Emailid);
const char *compare_stmt = [selectSql UTF8String];
NSMutableArray *resultarray = [[NSMutableArray alloc]init];
if (sqlite3_prepare_v2(database, compare_stmt,-1, &statement,
NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW)
{
NSString *userName =[[NSString alloc]initWithUTF8String:
(const char *)sqlite3_column_text(statement, 1)];
[resultarray addObject:userName];
NSString *password =[[NSString alloc]initWithUTF8String:
(const char *)sqlite3_column_text(statement, 2)];
[resultarray addObject:password];
return resultarray;
}
else
{
NSLog(@"not found");
return nil;
}
}
}
return nil;
}
-(NSArray*)studentdetailbyTableview:(NSString*)email;
{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSString *selectSql = [NSString stringWithFormat:
@"SELECT name,age,department FROM
USERDETAILS Where email =\"%@\"",email];
NSLog(@"------->%@",email);
const char *insert_stmt = [selectSql UTF8String];
NSMutableArray *resultarray = [[NSMutableArray alloc]init];
if (sqlite3_prepare_v2(database, insert_stmt,-1, &statement,
NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW)
{
NSString *userName =[[NSString alloc]initWithUTF8String:
(const char *)sqlite3_column_text(statement, 0)];
[resultarray addObject:userName];
NSString *age =[[NSString alloc]initWithUTF8String:(const
char *)sqlite3_column_text(statement, 1)];
[resultarray addObject:age];
NSString *department =[[NSStrin alloc]initWithUTF8String:
(const char *)sqlite3_column_text(statement, 2)];
[resultarray addObject:department];
return resultarray;
}
{
NSLog(@"not found");
return nil;
}
}
}
return nil;
}
@end
寄存器 VI.H
#import <UIKit/UIKit.h>
#import "DBDatabase.h"
@interface RegisterViewController :UIViewController
<UITextFieldDelegate,UIPickerViewDelegate,UIPickerViewDataSource>
@property (weak, nonatomic) IBOutlet UITextField *usernameText1;
@property (weak, nonatomic) IBOutlet UITextField *emailidText2;
@property (weak, nonatomic) IBOutlet UITextField *passwordText3;
@property (weak, nonatomic) IBOutlet UITextField *confirmpwdText4;
@property (weak, nonatomic) IBOutlet UITextField *dobText5;
@property (weak, nonatomic) IBOutlet UITextField *depatmentText6;
@property (strong,nonatomic)NSArray *depmentArray;
- (IBAction)registerButton:(id)sender;
@property (weak, nonatomic) IBOutlet UIPickerView *departmentPicker;
@property (weak, nonatomic) IBOutlet UIButton *registerBttn;
@结尾
寄存器视图.M
#import "RegisterViewController.h"
#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import "DetailtableviewViewController.h"
@interface RegisterViewController ()
@end
@implementation RegisterViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"NEW USER";
_departmentPicker.hidden=YES;
_depmentArray = [[NSArray alloc]initWithObjects:@"Computer
Science",@"Civil",@"Mechanical",@"Electonic",nil];
_registerBttn.enabled =NO;
}
//- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:
(NSRange)range replacementString:(NSString *)string
//{
// NSInteger maxlength = 25;
// {
// if(textField == _usernameText1)
// {
// maxlength =15;
// }
// else if(textField ==_dobText5)
// {
// maxlength =2;
// }
//
// NSUInteger length =[textField.text length]+[string length]
- range.length;
// return !(length >maxlength);
//
// }
//}
-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
}
#pragma mark textfield delegate
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
-(BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range replacementString:
(NSString *)string {
if ((_usernameText1.text.length >0) && (_emailidText2.text.length
>0) && (_passwordText3.text.length >0) &&
(_confirmpwdText4.text.length >0) && (_dobText5.text.length >0))
//&& (textField == _depatmentText6)
{
_registerBttn.enabled =YES;
}
else{
_registerBttn.enabled =NO;
}
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if( (_usernameText1.text.length >0) && (_emailidText2.text.length >0)
&& (_passwordText3.text.length >0) && (_confirmpwdText4.text.length
>0) && (_dobText5.text.length >0)
&& (textField == _depatmentText6)) {
// _registerBttn.enabled=YES;
_departmentPicker.hidden=NO;
}
else
{
//_registerBttn.enabled=NO;
_departmentPicker.hidden=YES;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark-UIPickerView Datasource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)
pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return _depmentArray.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:
(NSInteger)row forComponent:(NSInteger)component
{
return [_depmentArray objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:
(NSInteger)row inComponent:(NSInteger)component
{
if (self.departmentPicker)
{
[_depatmentText6 setText:[NSString stringWithFormat:@"%@",
[_depmentArray objectAtIndex:row]]];
_departmentPicker.hidden=YES;
}
}
- (IBAction)registerButton:(id)sender {
BOOL success = NO;
if ([_usernameText1.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your name" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.usernameText1 becomeFirstResponder];
}];
[alert addAction:ok];
[_usernameText1 becomeFirstResponder];
[self presentViewController:alert animated:YES completion:nil];
}
else if([_emailidText2.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your email" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action)
{
[self.emailidText2 becomeFirstResponder];
}];
[_emailidText2 becomeFirstResponder];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if(![self NSStringIsValidEmail:self.emailidText2.text ]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your valid emailid" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.emailidText2 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if ([_passwordText3.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your password" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.passwordText3 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if (_passwordText3.text.length<6) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter the password greater then six characters" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.passwordText3 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if([_confirmpwdText4.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter the confirm password" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.confirmpwdText4 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if (_confirmpwdText4.text.length<6) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter the confirmpassword greater then sixcharacters" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.confirmpwdText4 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if ([_dobText5.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your age" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.dobText5 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if ([_depatmentText6.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your department" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.depatmentText6 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if (![_passwordText3.text isEqualToString:_confirmpwdText4.text]) {
{
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your password" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.confirmpwdText4 becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
}
else {
success = [[DBDatabase getSharedInstance]saveData:_usernameText1.text email:_emailidText2.text password: _passwordText3.text confirmpassword:_confirmpwdText4.text age:_dobText5.text department:_depatmentText6.text];
_departmentPicker.hidden=YES;
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"SUCCESS ALERT" message:@"New User Registered succesfully" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel action");
}];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"OK action");
[self.navigationController popViewControllerAnimated:YES];
_usernameText1.text=@"";_emailidText2.text=@"";_passwordText3.text=@"";_confirmpwdText4.text=@"";_dobText5.text=@"";_depatmentText6.text=@"";
[self performSegueWithIdentifier:@"New User" sender:self];
}];
[alert addAction:cancelAction];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
}
if (success == NO) {
{
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"NIL" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:ok];
[self presentViewController:alert animated:YES
completion:nil];
}
}
}
@end
查看 CONTR.H(登录)
#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import "DBDatabase.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *emailidText;
@property (weak, nonatomic) IBOutlet UITextField *passwordText;
- (IBAction)newregisterButton2:(id)sender;
- (IBAction)loginButton1:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *logBttn;
@end
VIEW CONTROLL.M
#import "ViewController.h"
#import "DBDatabase.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title=@"LOGIN FORM";
self.logBttn.enabled =NO;
}
-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if((_emailidText.text.length > 0) && (_passwordText.text.length <10))
{
_logBttn.enabled =YES;
}
else {
_logBttn.enabled = NO;
}
}
#pragma mark-UITextFieldDelegate
-(BOOL) textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)newregisterButton2:(id)sender
{
[self performSegueWithIdentifier:@"add" sender:self];
}
- (IBAction)loginButton1:(id)sender {
NSArray *data =[[DBDatabase
getSharedInstance]findingEmailid:_emailidText.text
password:_passwordText.text];
if( [_emailidText.text isEqualToString:[NSString stringWithFormat:@"%@",[data objectAtIndex:1]]] ||
[_passwordText.text isEqualToString:[NSString stringWithFormat:@"%@",[data objectAtIndex:2]]]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"SUCCESS ALERT" message:@"New User Login success" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"OK action");
[self performSegueWithIdentifier:@"Detail" sender:self];
_emailidText.text=@"";
_passwordText.text=@"";
}];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
[self.activityView startAnimating];
// [self.activityView stopAnimating];
}
else if(self.emailidText == nil || [self.emailidText.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your emailid" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle
:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.emailidText becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if(![self NSStringIsValidEmail:_emailidText.text ]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter your valid emailid" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle
:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.emailidText becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if(self.passwordText == nil || [self.passwordText.text isEqualToString:@""]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter you password" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle
:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.passwordText becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else if(![_passwordText.text isEqualToString:[NSString stringWithFormat:@"%@",[data objectAtIndex:2]]]) {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Enter correct password" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle
:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self.passwordText becomeFirstResponder];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
else {
UIAlertController *alert =[[UIAlertController alloc]init];
alert =[UIAlertController alertControllerWithTitle:@"WARNING ALERT" message:@"Email is not register" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * ok =[UIAlertAction actionWithTitle:@"Not Register" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
[self performSegueWithIdentifier:@"add" sender:self];
_emailidText.text=@"";
_passwordText.text=@"";
}];
[alert addAction:ok];
_emailidText.text=@"";
_passwordText.text=@"";
[self presentViewController:alert animated:YES completion:nil];
}
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:
(id)sender {
if ([segue.identifier isEqualToString:@"Detail"]) {
DetailtableviewViewController *obj =
segue.destinationViewController;
obj.mailid = _emailidText.text;
}
// Get the new view controller using [segue
destinationViewController].
// Pass the selected object to the new view controller.
}
@end
详细表视图.H
#import <UIKit/UIKit.h>
#import "DBDatabase.h"
@interface DetailtableviewViewController :
UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *detailView;
@property (strong,nonatomic)NSString *mailid;
@end
细节.M
#import "DetailtableviewViewController.h"
#import "DetailTableViewCell.h"
@interface DetailtableviewViewController ()
@end
@implementation DetailtableviewViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [NSString stringWithFormat:@"%@",self.mailid];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark-UITableView datasourse
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellid = @"cell";
DetailTableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:cellid];
NSArray *data=[[DBDatabase
getSharedInstance]studentdetailbyTableview:[NSString
stringWithFormat:@"%@",self.title]];
{
cell.nameText.text = [NSString stringWithFormat:@"%@",[data
objectAtIndex:0]];
cell.ageText.text =[NSString stringWithFormat:@"%@",[data
objectAtIndex:1]];
cell.departmentText.text = [NSString stringWithFormat:@"%@",[data
objectAtIndex:2]];
return cell;
}
}
/*
#pragma mark - Navigation
@end
详细信息表格.H
#import <UIKit/UIKit.h>
@interface DetailTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameText;
@property (weak, nonatomic) IBOutlet UILabel *ageText;
@property (weak, nonatomic) IBOutlet UILabel *departmentText;
@end
细节细胞.M
import "DetailTableViewCell.h"
@implementation DetailTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end