後我有兩個視點控制器說一個 & 乙int值變爲零popViewController
在啊,我做
{
int cId;
bool selected;
}
@property (readwrite) int cId;
在上午我做
@synthesize cId;
- (void) viewWillAppear : (BOOL) animated
{
//It will only call if its popBacked
if(selected==YES) //I set it to YES some where in my A.m and its push to : B
{
selected=NO;
NSLog(@"%d",cId); //getting 0 (zero)
}
}
在B.m我做
#import "A.h"
- (void) sentBack : (int) cIdValue
{
A *obj=[A alloc] init];
obj.cId=cIdValue;
NSLog(@"%d",obj.cId); //Its print properly
[self.navigationController popViewControllerAnimated:YES];
}
我的問題是,當我彈回到它的價值變化,並設置爲0(零)。所以我無法訪問我的正確密碼。爲什麼是變化?我做錯了什麼?任何幫助,建議是有幫助的。 在此先感謝。
感謝您的回答,當我嘗試了您的更改後,它顯示了一個錯誤,例如,類型爲UIViewController **的對象上未找到**屬性cId。 – Hemang 2012-03-19 11:59:00
Hemang,現在嘗試上面的代碼將明確地解決您的問題。我已經編輯了一點代碼。 – Kuldeep 2012-03-19 12:02:39
感謝它的工作! :)你能告訴我,爲什麼我在上面的代碼中錯了(在我的問題中)!這將有所幫助。 – Hemang 2012-03-19 12:08:56