从服务获取输入(URL)

时间:2016-11-25 11:58:45

标签: ios objective-c uisegmentedcontrol

我有一组文本字段和分段控制。 我必须从服务输入到所有UIElements,获得文本字段的正确输入,但不是SegmentedControl。下面是我的代码和ScreenShot附加Please check the image for issue with SegmentedControl TIA

@interface EditBasicProfileViewController ()
@property(nonatomic,strong)NSMutableDictionary *userDict;

@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;

@property (strong, nonatomic) IBOutlet UIView *basicProfileView;
@property (strong, nonatomic) IBOutlet UITextField *txtCellPhone;
@property (strong, nonatomic) IBOutlet UITextField *txtWorkPhone;
@property (strong, nonatomic) IBOutlet UITextField *txtAdress;
@property (strong, nonatomic) IBOutlet UITextField *txtCountry;
@property (strong, nonatomic) IBOutlet UITextField *txtState;
@property (strong, nonatomic) IBOutlet UITextField *txtCity;
@property (strong, nonatomic) IBOutlet UITextField *txtMotherTongue;

@property (strong, nonatomic) IBOutlet UITextField *txtZipcode;

@property (strong, nonatomic) IBOutlet UISegmentedControl *genderSegment;

@property (strong, nonatomic) IBOutlet UISegmentedControl *seekingGenderSegment;

- (IBAction)genderSegmentValueChanged:(id)sender;
- (IBAction)seekingGenderSegmentValueChanged:(id)sender;

- (IBAction)btnCountry:(id)sender;

- (IBAction)btnState:(id)sender;

- (IBAction)btnCity:(id)sender;

- (IBAction)btnMotherTongue:(id)sender;

- (IBAction)btnUpdateClicked:(id)sender;


@property (strong, nonatomic) IBOutlet UIButton *updateButton;


@end

@implementation EditBasicProfileViewController

- (void)viewDidLoad {
    [super viewDidLoad];


    // Do any additional setup after loading the view from its nib.

    [super viewDidLoad];
    [self.scrollView addSubview:_basicProfileView];
    [_scrollView
     setContentSize:self.basicProfileView.frame.size];

    gender=@"0";
    seekingGender=@"1";
    _basicProfileView.backgroundColor=[UIColor clearColor];


    NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
    [dict setObject:UserId forKey:@"userId"];
    [self ProfileDisplayService:dict];

}

- (IBAction)genderSegmentValueChanged:(id)sender {
    if (_genderSegment.selectedSegmentIndex==0)
    {
        gender=@"0";

    }
    else
    {
        gender=@"1";
    }
}

- (IBAction)seekingGenderSegmentValueChanged:(id)sender {
    if (_seekingGenderSegment.selectedSegmentIndex==0)
    {
        seekingGender=@"0";

    }
    else
    {
        seekingGender=@"1";
    }

}

-(void)setupValues
{
    gender =[_userDict objectForKey:@"UserGender"];
    seekingGender = [_userDict objectForKey:@"SeekingGender"];
    _txtCellPhone.text=[_userDict objectForKey:@"UserPhone"];
    _txtWorkPhone.text=[_userDict objectForKey:@"UserWorkPhone"];
    _txtAdress.text=[_userDict objectForKey:@"UserAddress"];
    _txtCountry.text=[_userDict objectForKey:@"UserCountryName"];
    _txtState.text=[_userDict objectForKey:@"UserStateName"];
    _txtCity.text=[_userDict objectForKey:@"UserCityName"];
    _txtMotherTongue.text=[_userDict objectForKey:@"motherTounge"];
    _txtZipcode.text=[_userDict objectForKey:@"UserZipCode"];
}

- (IBAction)btnUpdateClicked:(id)sender {

    reqType=@"BasicDtls";
 [self callEditProfileService:dict];
    }

-(void)ProfileDisplayService:(NSMutableDictionary *)dict
{
 NSString * post = [[NSString alloc]initWithFormat:@"reqType=BasicDtls&userId=%@",UserId];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"Some Url"]];
    RBConnect = [[RBConnection alloc]init];
    RBConnect.delegate = self;
    [RBConnect postRequestForUrl:url postBody:post];
}

#pragma mark - MRConnection Delegate Methods

- (void)jsonData:(NSDictionary *)jsonDict
{
    [SVProgressHUD dismiss];

    NSMutableArray *jsonArr;

    jsonArr=[jsonDict objectForKey:@"DataTable"];
    if (![jsonArr isEqual:[NSNull null]]) {

        if ([[jsonArr objectAtIndex:0] objectForKey:@"ABSDetails"]) {
            NSMutableDictionary *userDict=[[jsonArr objectAtIndex:0] objectForKey:@"ABSUserDtls"];

           gender = [userDict objectForKey:@"UserGender"];
           seekingGender = [userDict objectForKey:@"SeekingGender"];

            _txtCellPhone.text=[userDict objectForKey:@"UserPhone"];
            _txtWorkPhone.text=[userDict objectForKey:@"UserWorkPhone"];
            _txtAdress.text=[userDict objectForKey:@"UserAddress"];
            _txtCountry.text=[userDict objectForKey:@"UserCountryName"];
            _txtState.text=[userDict objectForKey:@"UserStateName"];
            _txtCity.text=[userDict objectForKey:@"UserCityName"];
            _txtMotherTongue.text=[userDict objectForKey:@"motherTounge"];
            _txtZipcode.text=[userDict objectForKey:@"UserZipCode"];


        }
 }

}

0 个答案:

没有答案