Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา



 

iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา

 



Topic : 103464

Guest




เกิดจากอะไรค่ะ

error แบบนี้ต้องแก้ยังไงค่ะ



Tag : Mobile, MySQL, iOS, iPhone, Objective-C, Mac







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-12-10 17:54:38 By : fern_105 View : 914 Reply : 6
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ในบทความผมก็ทำแบบ Step by Step แล้วน่ะครับ ทำไมยังมี Error อีก






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-10 18:52:08 By : mr.win
 


 

No. 2

Guest


เพราะใช้ xcode 5 หรือป่าวไม่แน่ใจ แล้วมันจะแก้ตรงไหน
Viewlogin.h
Code (Objective-C)
#import <UIKit/UIKit.h>

@interface Viewlogin : UIViewController{
    IBOutlet UITextField*txtID;
    IBOutlet UITextField*txtPassword;
    NSMutableData*inputlogin;
    UIAlertView*loging;
    

    
}


@property (nonatomic,strong)IBOutlet UITextField *txtID;
@property (nonatomic,strong) IBOutlet UITextField *txtPassword;
@property(nonatomic,strong)NSMutableData *inputlogin;
@property(nonatomic,strong)UIAlertView*loging;
@property(nonatomic,strong)UIButton*btnClose;
@property(nonatomic,strong)UIButton*btnLogin;

- (IBAction)btnLogin:(id)sender;
- (IBAction)btnClose:(id)sender;




Viewlogin.m
Code (Objective-C)
#import "Viewlogin.h"
#import "loginViewController.h"


@implementation Viewlogin
@synthesize txtID;
@synthesize txtPassword;
@synthesize inputlogin;
@synthesize btnLogin;
@synthesize loging;



- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)clearInputText:(id)sender {
    txtID.text = @"";
    txtPassword.text = @"";
}

- (IBAction)btnLogin:(UIBarButtonItem *)sender {
    
    // Show Progress Loading...
    
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    
    loging
    = [[UIAlertView alloc] initWithTitle:@"" message:@"Login Checking..." delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
    UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    [loging addSubview:progress];
    [progress startAnimating];
    [progress release];
    [loging show];
    
    
    //sUsername&sPassword
    NSString *post = [NSString stringWithFormat:@"sID=%@&sPassword=%@",[txtID text],[txtPassword text]];
    
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    
    NSURL *url = [NSURL URLWithString:@"http://localhost:8888/checkLogin.php"];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
	[request setHTTPBody:postData];
    
    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
    
    
    
    if (theConnection) {
        self.inputlogin = [[NSMutableData data] retain];
    } else {
		UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad"  delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
		[connectFailMessage show];
		[connectFailMessage release];
    }
    
}

- (IBAction)btnClose:(id)sender {
}

//- (IBAction)btnClose:(id)sender {
//}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [inputlogin setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    sleep(3);
    [inputlogin appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    
    // ปิด Progress
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [loging dismissWithClickedButtonIndex:0 animated:YES];
    
    [connection release];
    [inputlogin release];
    
    // inform the user
    UIAlertView *didFailWithErrorMessage = [[UIAlertView alloc] initWithTitle: @"เกิดข้อผิดพลาด " message: @"ไม่สามารถเชื่อมต่อกับเซิร์ฟเวอร์ได้"  delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [didFailWithErrorMessage show];
    [didFailWithErrorMessage release];
	
    
    //inform the user
    NSLog(@"Connection failed! Error - %@", [error localizedDescription]);
    
}


- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    // ปิด Progress
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [loging dismissWithClickedButtonIndex:0 animated:YES];
    
    
    // Return Status E.g : { "Status":"1", "MemberID":"1", "Message":"Login Successfully" }
    // 0 = Error
    // 1 = Completed
    
    if(inputlogin)
    {
        
        id jsonObjects = [NSJSONSerialization JSONObjectWithData:inputlogin options:NSJSONReadingMutableContainers error:nil];
        
        // value in key name
        NSString *strStatus = [jsonObjects objectForKey:@"Status"];
        NSString *strID = [jsonObjects objectForKey:@"ID"];
        NSString *strMessage = [jsonObjects objectForKey:@"Message"];
        NSString *strName = [jsonObjects objectForKey:@"FNameE"];
        NSLog(@"Status = %@",strStatus);
        NSLog(@"ID = %@",strID);
        NSLog(@"postID = %@",txtID.text);
        NSLog(@"Message = %@",strMessage);
        NSLog(@"Name = %@",strName);
        
        //ดึงID,PasswordจากUserDefaults
        
        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        
        // saving an NSString
        [prefs setObject:txtID.text forKey:@"ID"];
        [prefs setObject:txtPassword.text forKey:@"password"];
        
        [prefs synchronize];
        
        
        // Login Completed
        if( [strStatus isEqualToString:@"1"] ){
            
            [self performSegueWithIdentifier:@"LoginSuccess" sender:self];
            
            
        }
        
        
        else // Login Failed
        {
            UIAlertView *error =[[UIAlertView alloc]
                                 initWithTitle:@"เกิดข้อผิดพลาด"
                                 message:strMessage delegate:self
                                 cancelButtonTitle:@"OK" otherButtonTitles: nil];
            [error show];
        }
        
        
    }
    
    // release the connection, and the data object
    [connection release];
    [inputlogin release];
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [txtID release];
    [txtPassword release];
    [super dealloc];
}

//- (IBAction)btnLogin:(id)sender {
//}

@end


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-10 19:32:20 By : fern_105
 

 

No. 3



โพสกระทู้ ( 1,579 )
บทความ ( 3 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ได้กำหนด File's Owner และ Inspector ในส่วนของ Outlet หรือเปล่าครับ
เพราะบทความพี่วิวส่วนมากจะ copy โค้ดไปดื้อๆไม่ได้นะครับ เราต้องกำหนด Outlet ก่อนอ่ะครับ
อันนี้ผมเดาเอานะ เพื่อลืมกันครับเพราะเจอหลายเคสที่ copy ไปวางแล้ว Run สคริปเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-12 23:04:07 By : somparn
 


 

No. 4



โพสกระทู้ ( 54 )
บทความ ( 0 )



สถานะออฟไลน์


เชคตัว sdk ของ simulator ดูครับว่ามันใช่ sdk เดียวกันหรือป่าว ถ้าไม่ใช่ลองเปิด preference แล้ว update ดู
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-12 23:34:59 By : j4kkapongz
 


 

No. 5



โพสกระทู้ ( 43 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ลองเช็คในส่วนของ outlet ให้ดีๆครับ

หลังๆผม เอาแค่
{
IBOutlet UITextField *txtN;
}
แค่นี้พอครับ



@property (strong,nonatomic) UITextField *txtN; อันนี้ผมไม่ค่อยใช้ละ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-13 13:57:00 By : kwampien
 


 

No. 6

Guest


ขอบคุณผู้รู้ทุกท่านมากค่ะ ตอนนี้ login ผ่านแล้วค่ะ ขอบคุณค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-18 17:58:02 By : fern105
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่