0
在我的代碼中,我定製了initWithNibName來接收它需要做的事情。下面的代碼:從推送的視圖控制器中返回一個值
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil theArray:(NSArray *)theDataArray theVal:(NSInteger)theDataValue bRange:(BOOL)isRange bColor:(BOOL)isColor{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.data = theDataArray;
self.selectedValue = theDataValue;
NSLog(@"NCG - initWithNibName setting selectedValue = %d.", self.selectedValue);
//self.originalValue = theDataValue;
self.isTheRange = isRange;
self.isTheColor = isColor;
self.selectedIndex = [self indexFromValue:theDataValue bRange:self.isTheRange bColor:self.isTheColor];
self.doneClicked = NO;
//NSLog(@"Selected Row = %d.", self.selectedIndex);
}
return self;
}
當這個觀點上運行,它更新self.selectedValue到一個新的價值。在視圖彈出後,我在視圖中需要這個值。
我該如何獲取這些數據?
這讓我糾正了我遇到的問題,所以我爲它+1了,並將其標記爲答案。我的問題是,我通過initWithNibname傳入的值對於推送新視圖的函數是本地的。一旦我將它們全局化爲調用視圖,一切都奏效了。感謝您指點我正確的方向。 – NCGrimbo
我很高興能夠提供幫助,因爲我自己從這個網站學到了很多東西。祝你好運! – codrut