Set button title programmatically - ios

I made a button in storyboard and associated it with an IBAction in my header file. How can I set the title of this button to the variable I made displayPhone and have it call that number as well?
.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#interface IBThirdViewController : UIViewController
#property (nonatomic, strong) PFRelation *agentRelation;
#property (nonatomic, strong) NSArray *agent;
#property (weak, nonatomic) IBOutlet UILabel *agentName;
#property (strong, nonatomic) IBOutlet UILabel *agentPhone;
#property (strong, nonatomic) IBOutlet UILabel *agentEmail;
#property (strong, nonatomic) IBOutlet UIImageView *agentImage;
- (IBAction)phoneButton:(id)sender;
#end
.m
#import "IBThirdViewController.h"
#import "IBAgentsTableViewController.h"
#interface IBThirdViewController ()
#end
#implementation IBThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//Find the Agent and show it
self.agentRelation = [[PFUser currentUser] objectForKey:#"agentRelation"];
PFQuery *query = [self.agentRelation query];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// success
self.agent = objects;
// Do something with the found objects
for (PFObject *object in objects) {
NSLog(#"name: %#", [object objectForKey:#"name"]);
NSLog(#"email: %#", [object objectForKey:#"email"]);
NSString *displayEmail = [object objectForKey:#"email"];
NSString *displayName = [object objectForKey:#"name"];
NSString *displayPhone = [object objectForKey:#"phone"];
PFFile *thumbnail = [object objectForKey:#"profilePic"];
NSURL *imageFileURL = [[NSURL alloc] initWithString:thumbnail.url];
NSData *imageData = [NSData dataWithContentsOfURL:imageFileURL];
self.agentEmail.text = displayEmail;
self.agentName.text = displayName;
self.agentPhone.text = displayPhone;
self.agentImage.image = [UIImage imageWithData:imageData];
}
} else {
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showEditAgent"]) {
IBAgentsTableViewController *viewController = (IBAgentsTableViewController *)segue.destinationViewController;
viewController.agents = [NSMutableArray arrayWithArray:self.agent];
}
}
- (IBAction)phoneButton:(id)sender {
}
#end

First of all you need connect button from xib with IBOutlet object:
#property (nonatomic, weak) IBOutlet UIButton *displayPhone;
Then set it's title in -(void)viewDidAppear:(BOOL)animated after loading data:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//...
// Load data here
//...
[self.displayPhone setTitle:displayPhone forState:UIControlStateNormal];
}
Finally implement IBAction method for button:
- (IBAction)phoneButton:(id)sender {
NSString *phone = [sender titleForState:UIControlStateNormal];
// Remove all chars except of digits
static NSString *const kDigitsString = #"0123456789";
phone = [[phone componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:kDigitsString] invertedSet]] componentsJoinedByString:#""];
// Initiate call
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phone]]];
}

It looks like you haven't connected the button to an outlet but only to an action.
First you need to connect it to an outlet (like you've done with the labels).
Then use...
[self.button setTitle:#"blah" forState:UIViewControlStateNormal];
Something like that anyway. I'm currently on my iPhone so I don't have auto complete.

If you want to change the title inside the IBAction method do:
[sender setTitle:#"My title" forState:UIControlStateNormal];
If you want to change in any other place you need a #property of uibutton, something like this
#property (strong, nonatomic) IBOutlet UIButton *phoneButtonProperty;
and connect it to your button and then
[phoneButtonProperty setTitle:#"My title" forState:UIControlStateNormal];

Related

My application crashes with this error - 'NSInvalidArgumentException'

I have created a program to retrieve JSON file and it achieved it
NSString *FilePath = [[NSBundle mainBundle]pathForResource:#"Message" ofType:#"json"];
NSData *data = [NSData dataWithContentsOfFile:FilePath];
NSError *error;
if(error){
NSLog(#"Error and CAn't retrive data: %#", error.localizedDescription);
}else{
NSDictionary * jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(#"Your Json Dictionary values are %#", jsonDict);
for(NSDictionary *valuesDictionary in jsonDict){
ShopCollectionObject *shopObject = [[ShopCollectionObject alloc]initWithID:[[valuesDictionary objectForKey:#"message_id"]integerValue] Name:[valuesDictionary objectForKey:#"product"] TimeAsPrice:[[valuesDictionary objectForKey:#"message_time"]integerValue] Avathar:[valuesDictionary objectForKey:#"item_image"] user:[valuesDictionary objectForKey:#"user_image"] Name_User:[valuesDictionary objectForKey:#"user_name"] LocationOfUser:[valuesDictionary objectForKey:#"locate_user"]];
But My app crashes here with the above error
[self.objectForArray addObject:shopObject];
}
}
Updated my shop collection code below
Shopcollection object.h
#import <Foundation/Foundation.h>
#interface ShopCollectionObject : NSObject
-(instancetype) initWithID: (int)msgID Name:(NSString *)Profile_name TimeAsPrice:(int) GivenTimeAsPrice Avathar:(NSString *) PhotoOfAvathar user:(NSString *)UserAvathar Name_User: (NSString *) UserNames LocationOfUser:(NSString *) USerLocationGiven;
#property (nonatomic) int msgID;
#property(nonatomic, strong)NSString* Name;
#property (nonatomic) int TimeAsPrice;
#property (nonatomic,strong) NSString* Avathar;
#property (nonatomic,strong) NSString* user;
#property (nonatomic,strong) NSString* Name_User;
#property(nonatomic,strong) NSString* LocationOfUser;
#end
Shopcollectionobject.m
#import "ShopCollectionObject.h"
#implementation ShopCollectionObject
-(instancetype)initWithID:(int)msgID Name:(NSString *)Profile_name TimeAsPrice:(int)GivenTimeAsPrice Avathar:(NSString *)PhotoOfAvathar user:(NSString *)UserAvathar Name_User:(NSString *)UserNames LocationOfUser:(NSString *)USerLocationGiven{
self = [super init];
if(self){
self.msgID = msgID;
self.Name = Profile_name;
self.TimeAsPrice = GivenTimeAsPrice;
self.Avathar = PhotoOfAvathar;
self.user = UserAvathar;
self.Name_User = UserNames;
self.LocationOfUser = USerLocationGiven;
}
return self;
}
#end
You likely aren't initializing your objectForArray. So when you try to call addObject, it's calling it on a null object.
ShopCollectionObject.h
#import <Foundation/Foundation.h>
#interface ShopCollectionObject : NSObject
#property (nonatomic) int message_id;
#property (strong, nonatomic) NSString *Name;
#property (nonatomic) int TimeAsPrice;
#property (strong, nonatomic) NSString *Avathar;//user,Name_User,LocationOfUser,message_id
#property (strong, nonatomic) NSString *user;
#property (strong, nonatomic) NSString *Name_User;
#property (strong, nonatomic) NSString *LocationOfUser;
-(instancetype) initWithID: (int)msgID Name:(NSString *)Profile_name TimeAsPrice:(int) GivenTimeAsPrice Avathar:(NSString *) PhotoOfAvathar user:(NSString *)UserAvathar Name_User: (NSString *) UserNames LocationOfUser:(NSString *) USerLocationGiven;
#property (nonatomic) int msgID;
#end
ShopCollectionObject.m
#import "ShopCollectionObject.h"
#implementation ShopCollectionObject
-(instancetype)initWithID:(int)msgID Name:(NSString *)Profile_name TimeAsPrice:(int)GivenTimeAsPrice Avathar:(NSString *)PhotoOfAvathar user:(NSString *)UserAvathar Name_User:(NSString *)UserNames LocationOfUser:(NSString *)USerLocationGiven{
self = [super init];
if(self){
self.msgID = msgID;
self.Name = Profile_name;
self.TimeAsPrice = GivenTimeAsPrice;
self.Avathar = PhotoOfAvathar;
self.user = UserAvathar;
self.Name_User = UserNames;
self.LocationOfUser = USerLocationGiven;
}
return self;
}
#end
ViewController.m
#import "ViewController.h"
#import "ShopCollectionObject.h"
#interface ViewController ()
{
NSMutableArray *objectForArray;
}
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
objectForArray = [[NSMutableArray alloc]init];
NSString *FilePath = [[NSBundle mainBundle]pathForResource:#"Message" ofType:#"json"];
NSData *data = [NSData dataWithContentsOfFile:FilePath];
NSError *error;
if(error){
NSLog(#"Error and CAn't retrive data: %#", error.localizedDescription);
}else{
NSDictionary * jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
for(NSDictionary *valuesDictionary in jsonDict){
ShopCollectionObject *shopObject = [[ShopCollectionObject alloc]initWithID:[[valuesDictionary objectForKey:#"message_id"]intValue] Name:[valuesDictionary objectForKey:#"product"] TimeAsPrice:[[valuesDictionary objectForKey:#"message_time"]intValue] Avathar:[valuesDictionary objectForKey:#"item_image"] user:[valuesDictionary objectForKey:#"user_image"] Name_User:[valuesDictionary objectForKey:#"user_name"] LocationOfUser:[valuesDictionary objectForKey:#"locate_user"]];
[objectForArray addObject:shopObject];
}
NSLog(#"%#",objectForArray);
ShopCollectionObject *data = objectForArray[0];
NSLog(#"%#",data.Name);
}
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
pls check this code

passing data to a view controller

Here is my button function where I pass the data.
The problem is Area and Country details are passed to the next ViewController but latitude and longitude return null.
In ViewController.m :
- (IBAction)forecast:(UIButton *)sender
{
ForecastViewController *sendDetails = [[ForecastViewController alloc] init];
NSArray *seperate = [full componentsSeparatedByString:#", "];
Area = seperate[0];
Country = seperate[1];
sendDetails.Area = Area;
sendDetails.Country = Country;
NSLog(#"%#%#",self.longitude,self.latitude);
NSString *lt = self.latitude;
NSString *ln = self.longitude;
sendDetails.longitude = lt;
sendDetails.latitude = ln;
}
In ForecastViewController.h
//
// ForecastViewController.h
// Weather App
//
// Created by Mac-Mini-2 on 10/02/16.
// Copyright © 2016 Mac-Mini-2. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import <Reachability.h>
#interface ForecastViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>
#property (weak, nonatomic) IBOutlet UILabel *place;
#property (weak, nonatomic) IBOutlet UITableView *table;
#property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
#property NSString *Area;
#property NSString *Country;
#property NSString *latitude;
#property NSString *longitude;
#end
In ForecastViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.table.delegate = self;
self.table.dataSource = self;
self.place.text = [NSString stringWithFormat:#"%#, %#",self.Area,self.Country];
locationName = [NSString stringWithFormat:#"%#, %#",self.Area,self.Country];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
metric = [defaults boolForKey:#"metric"];
Reachability *reach = [Reachability reachabilityWithHostName:#"www.google.com"];
NSInteger x = [reach currentReachabilityStatus];
if (x > 0)
{
reachable = YES;
NSLog(#"%#, %#",self.latitude,self.longitude);
[self getForecast:self.latitude longitudes:self.longitude];
}
else
{
reachable = NO;
[self getData];
errorMsg = #"Because of unavailability of Network Realtime information wont be available.";
[self performSelectorOnMainThread:#selector(displayAlert) withObject:NULL waitUntilDone:YES];
}
[reach startNotifier];
}
Please let me know where I could have gone wrong here.
I checked by logging the data onto console. The area and country is printed but longitude and latitude give null values.
if you are doing a push to ForecastViewController, maybe implementing prepareForSegue:sender: is your best option.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"viewForecast"]){
NSArray *seperate = [full componentsSeparatedByString:#", "];
Area = seperate[0];
Country = seperate[1];
[(ForecastViewController *) [segue destinationViewController] setArea:area];
[(ForecastViewController *) [segue destinationViewController] setCountry:country];
...
...
}
}
Could I the that latitude and longitude are stored as numbers in the first controller? Are you sure that 'sendDetails.latitude' and 'longitude' are set correctly in 'ViewController'?
I think you need to edit two point firstly in ForecastViewController.h set
#property (Strong, nonatomic) NSString *Area;
#property (Strong, nonatomic) NSString *Country;
#property (Strong, nonatomic) NSString *latitude;
#property (Strong, nonatomic) NSString *longitude;
and #synthsize it in ForecastViewController.m.
secondly:-
- (IBAction)forecast:(UIButton *)sender
{
ForecastViewController *sendDetails = [self.storyboard instantiateViewControllerWithIdentifier:#"your ForecastViewController name in storyboard"];
NSArray *seperate = [full componentsSeparatedByString:#", "];
Area = seperate[0];
Country = seperate[1];
sendDetails.Area = Area;
sendDetails.Country = Country;
NSLog(#"%#%#",self.longitude,self.latitude);
NSString *lt = self.latitude;
NSString *ln = self.longitude;
sendDetails.longitude = lt;
sendDetails.latitude = ln;
[self.navigationController pushViewController:sendDetails animated:YES];
}

PFObject Subclass Not Loading Objective-C

I'm running into some trouble with a PFObject subclass. I've gone thru all of the proper setup (registering the subclass in the delegate, setting the class name, etc). But for some reason I can't get the object to load without crashing it in the view that it's supposed to be loading in.
Passing the Object
if ([segue.identifier isEqualToString:#"toPostView"])
{
pbPostViewController *postView = [pbPostViewController new];
postView = (pbPostViewController *)segue.destinationViewController;
[postView setPostToLoad:_selectedPost];
}
Receiving View.h
// Copyright (c) 2015 Chris Culos. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "PALongTextView.h"
#import "pbPost.h"
#interface pbPostViewController : UIViewController
#property (strong, nonatomic) pbPost *postToLoad;
Receiving View.m
#import "pbPost.h"
#interface pbPostViewController ()
#end
#implementation pbPostViewController
- (void)viewDidLoad {
pbPost *post = [pbPost postWithObject:_objectToLoad];
NSLog(#"post: %#", post);
// _timeStampLabel.text = post.postTimeStamp;
_userNameLabel.text = [post.postOwner valueForKey:#"username"];
_profileImage.image = [post.postOwner valueForKey:#"profileImage"];
_postDescriptionView.text = post.postDescriptionString;
_bookmarkCounterLabel.text= [NSString stringWithFormat:#"%li bookmarks", post.postBookmarkedArray.count];
_postContentView.text = #"POST CONTENT PAGE 123 456 ETC ETC ETC";
[super viewDidLoad];
//
pbPost.h
#interface pbPost : PFObject <PFSubclassing>
{
}
#property (nonatomic, retain) NSDate *postTimeStamp;
#property (nonatomic, retain) NSString *postDescriptionString;
#property (nonatomic, retain) NSString *postContentString;
#property (nonatomic, retain) NSString *postBookmarkString;
#property (nonatomic, retain) NSString *postPageCounterString;
#property (nonatomic, retain) NSArray *postBookmarkedArray;
#property (nonatomic, retain) PFFile *postOwnerProfileImage;
#property (nonatomic, retain) NSNumber *postFontSize, *totalPages;
#property (nonatomic, retain) PFUser *postOwner;
+ (pbPost *) postWithObject: (PFObject *)object;
pbPost.m
#implementation pbPost
#dynamic postContentString, postBookmarkString, postDescriptionString, postPageCounterString, postTimeStamp, commentTableView, commentButton, bookMarkButton, postOwnerProfileImage, optionsButton, postFontSize, totalPages, postBookmarkedArray, postOwner;
+ (void)load
{
[self registerSubclass];
}
+ (NSString *)parseClassName
{
return #"userPosts";
}
+ (pbPost *) postWithObject: (PFObject *)object
{
// NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
// [dateFormat setDateFormat:#"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
// [dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:#"UTC"]];
pbPost *post = [pbPost postWithObject:object];
[post fetchInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (!error) {
post.postTimeStamp = [object valueForKey:#"createdAt"];
post.postDescriptionString = [object valueForKey:#"titleSummary"];
post.postFontSize = [object valueForKey:#"fontSize"];
post.postContentString = [object valueForKey:#"postContent"];
post.totalPages = [object valueForKey:#"numPages"];
post.postBookmarkedArray = [object valueForKey:#"bookmarkedBy"];
post.postOwner = [object valueForKey:#"postOwner"];
post.postOwnerProfileImage = [post.postOwner valueForKey:#"profileImage"];
NSLog(#"LOAD THE THING!: %#", post);
}
else
{
NSLog(#"Error Loading Post: %#", error);
}
}];
return post;
}
Under this circumstance; I'm getting an EXC_BAD_ACCESS at + (pbPost *)postWithObject:(PFObject *)object in the implementation file.
I feel like I'm missing something very simple here; what can it be? Thanks in advance for your help again everyone! This has stumped me for a little while and I need to get some outside help.
Since you're passing the pbPost object, you don't need to call the + (pbPost *)postWithObject:(PFObject *)object at all. To create a new instance of your PFObject subclass, you can just call:
pbPost *post = [pbPost object];

about sharedInstance SOMotionDetector and SOStepDetector objective-c

I'm working on the following code, which has the steps of a person walking. but every time I step from one view to another the counter stops. I am working with SOMotionDetector.
NOTE: when printing to console the steps that continues to function even changing views.
#import "SOMotionDetector.h"
#import "SOStepDetector.h"
#interface ContarPasos ()<SOMotionDetectorDelegate>
{
int stepCount;
}
#property (weak, nonatomic) IBOutlet UILabel *speedLabel;
#property (weak, nonatomic) IBOutlet UILabel *stepCountLabel;
#property (weak, nonatomic) IBOutlet UILabel *motionTypeLabel;
#property (weak, nonatomic) IBOutlet UILabel *isShakingLabel;
#end
#implementation ContarPasos
- (void)viewDidLoad
{
[super viewDidLoad];
__strong ContarPasos *weakSelf = self;
[SOMotionDetector sharedInstance].motionTypeChangedBlock = ^(SOMotionType motionType) {
NSString *type = #"";
switch (motionType) {
case MotionTypeNotMoving:
type = #"No estas moviendote";
break;
case MotionTypeWalking:
type = #"Caminando";
break;
case MotionTypeRunning:
type = #"Corriendo";
break;
case MotionTypeAutomotive:
type = #"Automotive";
break;
}
weakSelf.motionTypeLabel.text = type;
};
[SOMotionDetector sharedInstance].locationChangedBlock = ^(CLLocation *location) {
weakSelf.speedLabel.text = [NSString stringWithFormat:#"%.2f km/h", [SOMotionDetector sharedInstance].currentSpeed * 3.6f];
};
[SOMotionDetector sharedInstance].accelerationChangedBlock = ^(CMAcceleration acceleration) {
BOOL isShaking = [SOMotionDetector sharedInstance].isShaking;
weakSelf.isShakingLabel.text = isShaking ? #"Corriendo":#"No corriendo";
};
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
[SOMotionDetector sharedInstance].useM7IfAvailable = YES; //Use M7 chip if available, otherwise use lib's algorithm
}
[[SOMotionDetector sharedInstance] startDetection];
[[SOStepDetector sharedInstance] startDetectionWithUpdateBlock:^(NSError *error) {
if (error) {
NSLog(#"%#", error.localizedDescription);
return;
}
stepCount++;
weakSelf.stepCountLabel.text = [NSString stringWithFormat:#"Pasos: %d", stepCount];
NSLog(#"always printed on console but not in the view: %d", stepCount);
}];
}

ios cannot add new marker after passing data back to parent ViewController with EXEC_BAD_ACCESS

I am trying to implement the module for setting the map parameters before adding the new marker.
The flow is initialing new SliderViewCOntroller from parent mapViewController. After setting the values at SliderViewController and saving their values, it passes back to the parent mapViewCOntroller with new coordinates added. For the time being, the variable for the coordinates are only the global variables on the mapViewCOntroller
Actually, after saving the parameters, it shows the EXEC_BAD)ACCESS (code=1 , address = 0xc)
The code highlights at the
[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil];
on the SliderViewController.m
Would you please tell me are there any other alternatives to pass the data back from child viewController to parent ViewController using protocols and delegate ?
The below is my working:
MapViewController.h
#import <MessageUI/MessageUI.h>
#import <GoogleMaps/GoogleMaps.h>
#import <UIKit/UIKit.h>
#import "SliderViewController.h"
#interface MapViewController : UIViewController<GMSMapViewDelegate , SliderViewControllerDelegate>{
}
#property (nonatomic) float verticalSliderValue;
#property (nonatomic) float circleSliderValue;
#end
MapViewController.m
//initiaing
-(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{
p = coordinate;
SliderViewController * sliderVC = [self.storyboard instantiateViewControllerWithIdentifier:#"SliderViewController"];
sliderVC.view.backgroundColor = [UIColor colorWithWhite:1.0 alpha:1.0];
sliderVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:sliderVC animated:YES completion:NULL];
[sliderVC release];
}
//receiving
- (void)passValue:(float )value1 : (float )valueCiruclar
{
NSLog(#"This was returned from ViewControllerB %ff",value1);
NSLog(#"This was returned from ViewControllerSlider %ff",valueCiruclar);
CheckPoints *myCar=[[CheckPoints alloc] init];
[myCar setState:0];
[myCar setLatitude:p.latitude];
[myCar setLongitude:p.longitude];
NSString* theTextValue = #"Desitnation";
[myCar setDesp:theTextValue];
[array addObject:myCar];
CheckPoints *lastChk = array.lastObject;
[self writeToTextFile:[NSString stringWithFormat:#"%#%#%#%#%#%#", lastChk.getDesp , #"\n",[NSString stringWithFormat:#"%f", lastChk.getLatitude],
#"\n", [NSString stringWithFormat:#"%f", lastChk.getLongitude], #"\n" ]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setFloat:lastChk.getLatitude forKey:#"lati"];
[defaults setFloat:lastChk.getLongitude forKey:#"longi"];
[defaults setObject:lastChk.getDesp forKey:#"desp"];
[defaults synchronize];
for (int i = 0; i < [array count]; i++) {
CheckPoints *current = [array objectAtIndex:i];
if(current.getLatitude != lastChk.getLatitude && current.getLongitude != lastChk.getLongitude){
[current setState:1];
NSString* previousTitle = [NSString stringWithFormat:#"%#%#", #"Checkpoint" ,[NSString stringWithFormat:#"%i", i+1]];
[current setDesp:previousTitle];
}
}
[self addMarkers];
}
SliderViewController.h
#import <UIKit/UIKit.h>
#import "EFCircularSlider.h"
#protocol SliderViewControllerDelegate <NSObject>
- (void)passData:(float )itemVertical : (float )itemCircular ;
#end
#interface SliderViewController : UIViewController
#property (strong, nonatomic) IBOutlet UILabel *uiValue;
#property (strong, nonatomic) IBOutlet UISlider *uiSlider;
#property (strong, nonatomic) IBOutlet UIButton *btnReset;
#property (strong, nonatomic) IBOutlet UILabel *uiValue2;
#property (strong, nonatomic) EFCircularSlider* circularSlider;
#property (nonatomic) float verticalSliderValue;
#property (nonatomic) float circleSliderValue;
#property (nonatomic) id <SliderViewControllerDelegate> delegate;
- (IBAction)reset:(id)sender;
- (IBAction)sliderChange:(id)sender;
- (void)buttonClicked: (id)sender;
#end
SliderViewController.m
- (IBAction)reset:(id)sender {
[self writeToTextFile:valueV :valueC];
self.uiValue.text =[NSString stringWithFormat:#"%.2f" , 0.00];
[self.uiSlider setValue:0.00];
self.uiValue2.text =[NSString stringWithFormat:#"%.2f" , 0.00];
[_circularSlider setCurrentValue:0.0f];
MapViewController * sliderVC = [self.storyboard instantiateViewControllerWithIdentifier:#"MapViewController"];
[self.delegate passData:_uiSlider.value :_circularSlider.currentValue ];
sliderVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil];
}

Resources