How would I be able to have an image show in a UIAlertView along with some text. Apparently this isn't available in iOS7, is this true? All I want is to replace some text with an image, preferably not by using custom libraries. The NSString *formula is the one I want to replace with an image.
NSString *title = [NSString stringWithFormat:#"BMI"];
NSString *mess = [NSString stringWithFormat:#"Body Mass Index, or BMI, is used by many health professionals to assess a patient's health. BMI is calculated by the formula:"];
NSString *formula = [NSString stringWithFormat:#" Weight(kg)/(Height(m)*Height(m))"];
// Combined message (mess) and Formula (formula)
NSString *combinedMess;
combinedMess = [mess stringByAppendingString:formula];
NSString *mess1 = [NSString stringWithFormat:#" Although this tool is useful in measuring a person's weight ratio, it becomes unrealiable for body builders and other extremes. BMI combined with a general indication of fitness level gives Quick Fit a clear view of the fitness level of the user."];
// Combined message (combinedMess) and message (mess1)
NSString *all;
all = [combinedMess stringByAppendingString:mess1];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: title
message: all
delegate: self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
This is not possible on iOS7 without creating your own version of an alert view. A quick google search came across this https://github.com/wimagguc/ios-custom-alertview which looks promising.
Per apple's documentation:
Subclassing Notes
The UIAlertView class is intended to be used as-is
and does not support subclassing. The view hierarchy for this class is
private and must not be modified.
https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html
Related
I'm trying to extract the phone number and email address from the address book on iOS8 and I open the person picker as follows:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], [NSNumber numberWithInt:kABPersonEmailProperty], nil];
[self presentViewController:picker animated:YES completion:nil];
When there are multiple phone numbers and multiple email addresses in the contact details, how do I select one of each?
Ideally, I'd like to be able to tick the preferred phone and then the preferred email address but it doesn't look like I can.
Anybody know how to do this please?
On a NSTextField I'm setting a custom font with a size of 140. The text is set to #"28". But as you can clearly see on the image, the text field has plenty of space on top. This only happens with certain type of fonts, not all of them. My question is what information from the font could be affecting the textfield that ends up cropping the text ? (Ascender, Cap Height ?). And if so, can I modify the font file to fix it ?
The baseline will vary between fonts. In addition, there are other metrics that vary. You can work around this problem with NSAttributedString. You could try varying the NSBaselineOffsetAttribute and from within a paragraph setMinimumLineHeight and setMaximumLineHeight. The following is an example. Make sure to create two textField labels and connect their outlets.
self.Label1.stringValue = #"Test Text";
//
// baseline is different for each font!
//
//self.Label2.stringValue = #"Test Text";
NSFont *otherFont = [NSFont fontWithName:#"MarkerFelt-Thin" size:40.0f];
NSNumber *baseline = [[NSNumber alloc] initWithFloat: 5.0f];
NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paraStyle setParagraphSpacingBefore:20.0f];
[paraStyle setMinimumLineHeight:30.0f];
[paraStyle setMaximumLineHeight:50.0f];
NSDictionary *otherFDict = [NSDictionary dictionaryWithObjectsAndKeys: paraStyle, NSParagraphStyleAttributeName,
otherFont, NSFontAttributeName, baseline, NSBaselineOffsetAttributeName, nil];
NSMutableAttributedString *otherText = [[NSMutableAttributedString alloc] initWithString:#"Test Text" attributes:otherFDict];
self.Label2.attributedStringValue = otherText;
Using the QTKit framework, I'm developing a little app.
In the app, I'm trying to append a movie after a other movie, which in essence is already working (most of the time), but I'm having a little trouble with the appended movie. The movie is which I'm appending to is quite big, like 1920x1080, and the appended movie is usually much smaller, but I never know what size it exactly is. The appended movie sort of stays its own size in the previous 1920x1080 frame, as seen here:
Is there anyone familiar with this? Is there a way I can scale the movie which I need to append to, to the size of the appended movie? There is no reference of such a thing in the documentation.
This is are some relevant methods:
`QTMovie *segmentTwo = [QTMovie movieWithURL:finishedMovie error:nil];
QTTimeRange range = { .time = QTZeroTime, .duration = [segmentTwo duration] };
[segmentTwo setSelection:range];
[leader appendSelectionFromMovie:segmentTwo];
while([[leader attributeForKey:QTMovieLoadStateAttribute] longValue] != 100000L)
{
//wait until QTMovieLoadStateComplete
}
NSDictionary *exportAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], QTMovieExport,
[NSNumber numberWithLong:kQTFileTypeMovie], QTMovieExportType, nil];
NSString *outputFile = [NSString stringWithFormat:#"%#.mov", onderwerp];
NSString *filepath = [[#"~/Desktop" stringByExpandingTildeInPath] stringByAppendingFormat:#"/%#", outputFile];
BOOL succes = [leader writeToFile:filepath withAttributes:exportAttributes error:&theError];
Leader is initialized like this:
NSDictionary *movieAttributes = [NSDictionary dictionaryWithObjectsAndKeys:path, QTMovieFileNameAttribute, [NSNumber numberWithBool:YES], QTMovieEditableAttribute, nil];
leader = [QTMovie movieWithAttributes: movieAttributes error:&error];
This contained all the information I need, although without using the QTKit framework. QTKit - Merge two videos with different width and height?
I've searched through all the questions and can't seem to find my answer.
I have the following IBAction. This is crashing every time you tap on the phone number. I have gone back to the DB and formatted the phone numbers to 5551235555 instead of (555)-123-5555.
- (IBAction)callPhone:(UIButton *)sender{
Bar *items = self.detailItem;
NSURL *pn = [NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", items.barPhone]];
[[UIApplication sharedApplication] openURL:pn];
}
- (void)setCallButton:(UIButton *)callButton{
Bar *items = self.detailItem;
[callButton setTitle:items.barPhone
forState:UIControlStateNormal];
}
Any code guidance would be appriciated.
Bar *items = self.detailItem; is not initiated, so that is why it is returning nil. Try the following:
Bar *items = [[Bar alloc] init];
items = self.detailItem;
Or what you should have done is make items an ivar for this particular class. Then you can initiate items once and use it throughout your class.
I want to try to make a weather app... but how do i get the weather info and use them in my app?
I heard about Google IPA but how to use it?
First pick the best weather API for your purpose:
https://stackoverflow.com/questions/507441/best-weather-apis
Most APIs, including Google, return their result in XML format.
Quickly written example code to get you started with the Google Weather API:
NSString * location = #"Amsterdam";
NSString * address = #"http://www.google.co.uk/ig/api?weather=";
NSString * request = [NSString stringWithFormat:#"%#%#",address,location];
NSURL * URL = [NSURL URLWithString:request];
NSError * error;
NSString* XML = [NSString stringWithContentsOfURL:URL encoding:NSASCIIStringEncoding error:&error];
// Extract current temperature the 'dirty' way
NSString * temp = [[[[XML componentsSeparatedByString:#"temp_c data=\""] objectAtIndex:1] componentsSeparatedByString:#"\""] objectAtIndex:0];
NSLog(#"It's currently %# degree in %#.", temp, location);
// Parse the XML with NSXMLDocument to extract the data properly
NSXMLDocument * doc = [[NSXMLDocument alloc] initWithXMLString:XML options:0 error:NULL];
Output:
It's currently 14 degree in Amsterdam.
I created sample iOS Weather app using- Swift,Protocaol oriented programming(POP), Codable, OpenWeatherMap Api, MVVM design pattern with Unit Test.
https://github.com/deepakiosdev/WeatherApp/tree/master
May be it will helpful for someone who is looking all these things.