Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6146017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:52:56+00:00 2026-05-23T18:52:56+00:00

I have a Main view with a landscapeview and a portraitview that gets loaded

  • 0

I have a Main view with a landscapeview and a portraitview that gets loaded as subviews of the wrapper view. Both the landscape view and portraitview has UIPickerView objects that are linked to them. In my source I have them all as properties and I also have a wrapper for the landscape and portrait pickers. They are defined as

@property (nonatomic, retain, readonly) IBOutlet UIPickerView *pickerTown;
@property (nonatomic, retain, readonly) IBOutlet UIPickerView *pickerType;
@property (nonatomic, retain, readonly) IBOutlet UIDatePicker *pickerFrom;
@property (nonatomic, retain, readonly) IBOutlet UIDatePicker *pickerTo;

@property (nonatomic, retain) IBOutlet UIPickerView *landscapePickerTown;
@property (nonatomic, retain) IBOutlet UIPickerView *landscapePickerType;
@property (nonatomic, retain) IBOutlet UIDatePicker *landscapePickerFrom;
@property (nonatomic, retain) IBOutlet UIDatePicker *landscapePickerTo;

@property (nonatomic, retain) IBOutlet UIPickerView *portraitPickerTown;
@property (nonatomic, retain) IBOutlet UIPickerView *portraitPickerType;
@property (nonatomic, retain) IBOutlet UIDatePicker *portraitPickerFrom;
@property (nonatomic, retain) IBOutlet UIDatePicker *portraitPickerTo;

And for each of the readonly wrappers I have

- (UIPickerView *) pickerTown
{
    if(self.landscapeView.superview)
    {
        return landscapePickerTown;
    }else
    {
        return portraitPickerTown;
    }
}

But when I am in portrait or landscape, and I try for instance to say

myHelper.selectedTown = [myHelper.towns objectAtIndex:[pickerTown selectedRowInComponent:0]];

I don’t get the selected value but just the first value in the array.

The data gets added as follows:

if(pickerView == landscapePickerType || pickerView == portraitPickerType) {
    return [myHelper.types objectAtIndex:row];
}else if(pickerView == landscapePickerTown || pickerView == portraitPickerTown){
    return [myHelper.towns objectAtIndex:row]; 
}else
{
    return @"";
}

and the array:

myHelper = [Helper sharedManager];
[myHelper.types addObject:@"None"];
[myHelper.types addObject:@"Food & Wine"];
[myHelper.types addObject:@"Test"];
[myHelper.towns addObject:@"None"];
[myHelper.towns addObject:@"Vanderbijlpark"];
[myHelper.towns addObject:@"Test"];

What am I doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:52:56+00:00Added an answer on May 23, 2026 at 6:52 pm

    If you are getting only the first element, it is indicative that [pickerTown selectedRowInComponent:0] is evaluating to zero always which will happen only if pickerTown is nil. That again is most likely due to outlet not being connected.

    But in this case I think you are accessing the instance variable directly and not the value the method returns. If you are using @synthesize for pickerTown, make that @dynamic. And change the statement to [self.pickerTown selectedRowInComponent:0] to access the value of the getter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main View that has a table which has it's own controller.
I have an app that has a main view that acts as a view
I have an iPhone app that hides the status bar. However, my main view
I have a view that sets its hidden when the user taps the main
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
Let me start off by describing my situation. I have a main view that
I have a main view that divided into 4 equally sized sub-views. I used
Greetings, Problem: I have a main view, that already is associated with a xib
I have an app where my main view accepts both touchesBegan and touchesMoved ,
I have an NSBox set up in my main view that accepts drag and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.