Make background image change based on time of day (Local time) - ios

Im making an app using Xcode5 and i want to have the background image (or Image View) of one of my View Controllers change between a set of images based on the local time
pretty much have a certain image show between
0600am - 1159am image1
1200pm - 1759pm image2
1800pm - 2359pm image3
0000am - 0559am image4.
Its my first time coding and i cant find anything on this matter so if someone can help me or walk me through it I would really appreciate it!
Thanks

Use something like this: How to Check if an NSDate occurs between two other NSDates to check your date ranges then call a method based on the results to change your background image to the correct one. Post some code if you are having trouble.

Related

iOS Photo Gallery Memory Leak / Crash when using Push Segues

I've created a small photo gallery which is presenting a new view controller with a larger version of the photo and some additional text when it is clicked:
The problem is - after going through a handful of images - the application crashes due to overuse of memory. I attempted to resolve this by compressing the images in order to leave a smaller memory footprint, but the issue remains and I'm not sure what else I can do to resolve this issue.
Also - there is almost no code to doing this since I'm using storyboard's push segues as well as the built in navigation item to go back between viewControllers.
P.S.
If you feel source code is necessary to provide insight in this instance - it can be found here:
https://www.dropbox.com/s/q1qq8pq4tzv8wyo/EXAMPLE%20BUILD.zip?dl=0
To resolve this issue you have to use this trick; Put a "placeHolder" image in your cell's imageview in "StoryBoard". Don't load the images all at once in your "ViewController", load them one by one by running a loop or in your "cellForRowAtIndexPath()" method and add a delay in each iteration (Load first image then add a delay, load second image and add a delay, then for third one and so on up to the last image).
If you want to know how to add a delay then check this link:
NSTimer - how to delay in Swift
To resolve this issue I simply resized the images - I noticed I accidentally used a gigantic (6000 x 4000) image and even though I compressed the images iOS had to crunch pretty hard to resize them into the view... thereby causing the memory leak and subsequent crash.
Resizing them to 600x400 did the trick.

UISlider to change UIImage brightness/contrast in Swift Playground is very laggy.

I am currently creating a filter app. The user has the option to change brightness, contrast, etc.
I have implemented the ability to change these attributes of the image and it currently works but when I test this in Xcode Playgrounds the slider is extremely slow and makes Xcode very laggy.
I assume this is because I have written this in a very inefficient way. I don't want to copy and paste all of my code to Stackoverflow (I want to avoid making this too complicated) so I have uploaded it on Github. Located Here if you download the repo and open the playground up it is 100% running and if you test the slider you will see it is very laggy.
I think what is making it so laggy is that I am reseting the image view every time the slider value is changed resulting in a new UIImage being assigned to it every fraction of a second. Here is a tiny snippet of what I I just said, in code. You will probably still have to look at the code I posted on github since I made some protocols and classes
slider.addTarget(c, action: #selector(c.BrightnessChanged(sender:)), for: .valueChanged)
func updateBrightness(sender:UISlider) {
controls.brightness(sender.value)
img.image = controls.outputUIImage()
}
I genuinely have no intention asking for a solution without having tried myself; I have searched all over the interwebs to figure this out with no success.
Thanks Stackoverflow homies!

Adding "stretchable" images to and image selected from gallery

Im trying to make an app for planning out where you want to put "shelves" on a wall (sounds strange i know ;) )
i have got it so the image is picked from the UIImagePickerController then loaded in a new ViewController i also have a button at the bottom of the ViewController that i want to open a list of images to select from that once selected the user can move around then stretch the required size if they don't like, delete and once they are happy i want my second button to save the image and put it into an email ready for sending.
I have looked at a few ways but none of them seem to be "adequate" would be so grateful anyone could suggest any ways or even help me with some code, I'm very new to this and this is my first app.
Im not too sure on the code you'd need to see as none of what is written yet is relevant to this part of the app
This is a 2 part so the first is, what way do i go about it?, the second is what code?
Thanks
-(UIImage *)GetStreachableImage
{
UIImage *takephotoButtonImagenormal = [UIImage imageNamed:CHOOSE_TAKE_NORMAL_IMAGE];
UIImage *strechableButtonImageNormal1 = [takephotoButtonImagenormal stretchableImageWithLeftCapWidth:takephotoButtonImagenormal.size.width/2 topCapHeight:takephotoButtonImagenormal.size.height/2];
takephotoButtonImagenormal=nil;
return strechableButtonImageNormal1;
}
try this

invert UIDatePicker colors in iOS 7

I want to start by saying that i would post this question on the Apple Dev Forums but because of the hacking attempt fiasco , or whatever that was, the forum has been offline for almost 2 weeks now and i need a solution for this as soon as possible.
In iOS 7 the UIDatePicker looks like this :
and a client asked to look like this :
(basically inverted).
I've tried a few things:
Setting the background to black and looping through all the view's subviews until i reach the labels that show the date itself and change their color to white. The problem is that The view has only one subview, and that subview doesn't have any subviews of it's own. So this solution doesn't work. (it did in ios6).
Applying a filter to the view's CALayer. The thing is that this is only possible on OS X not on iOS, for some unknown reason.
Playing with UIApperance protocol. From what i've read this should work but what i've tried didn't and i don't have extensive experience with this to figure out why not.
Any ideas what i can try? Is this even possible? Did i made a mistake in my approach of the problem?
Try this out :
Put this code in -(void)viewDidLoad
[datePicker setValue:[UIColor whiteColor] forKey:#"textColor"];
Swift:
datePicker.setValue(UIColor.white, forKey: "textColor")
Don't know if this is still relevant but on Swift 3 / Xcode 8 you can simply do this:
let datePicker = UIDatePicker()
datePicker.datePickerMode = UIDatePickerMode.date
// Sets the text color
datePicker.setValue(UIColor.white, forKey: "textColor")
// Sets the bg color
datePicker.backgroundColor = UIColor.black.withAlphaComponent(0.6)
textField.inputView = datePicker
I spent quite a bit of time struggling with the same problem. At first, I've put a UIDatePicker on a black background and was wondering why it is invisible...
I ended up placing a white UIView as a background for the date picker, so while the whole view is black, the date picker is white. It actually looks okay, although thankfully I don't have a client who would dictate the design.
One possible argument for a client: the old, pre-iOS7 date picker, also had a predefined non-customisable background.
What you want is possible, but it will be called Custom Date Picker.
Below is the link where you will find what you wanted.
https://www.cocoacontrols.com/controls/simpledatepicker
If you need more, take a loot at below link.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=datepicker
Well I understand your frustration, but iOS7 is under NDA. Usually this kind of views are made using layers, beacuse of sublayerTransform that can make perspective giving the idea of 3D. I would check sublayers if you don't see subviews.
The other poin is that I would not hack too much views/layers hierachy, ios<=6 to ios7 transition shown that hacking isn't a good idea.
UIAppereance protocol is probably the way to go, becauase it makes you change what you can change (without screwing that in the future), maybe you can set a backgroundImage, try to set a 1x1pixel of a blck color png, you should also see an attributed string property, or text property.
I dont think its possible to do that directly by changing the properties of the default UIDatePicker , although you can use custom controls to do it.
This might help,
MWDatePicker - https://github.com/mwermuth/MWDatePicker (Found it in cocoa controls -https://www.cocoacontrols.com/controls/mwdatepicker)
according to the iOS Design Resources:
You cannot customize the appearance of date pickers.
I would suggest one of the below:
Redesign your UI to use the black text
Use a customer datepicker
You should tell your client that his suggestion is against the design principles of iOS 7, which indeed it is. I am not a great fan of iOS 7 myself, but we should all give it a go. Your client should accept the standard iOS 7 UI provisionally, until he is in a position to make an informed judgement. Designing an app based on his initial impressions is a recipe for disaster.

iOS Launch a FGallery with start point

I wonder if we can launch the FGallery component at a given start point.
https://github.com/gdavis/FGallery-iPhone
I tried to use the loadFullsizeImageWithIndex: method used by the thumbnails grid but... fail.
Anyone did that ?
Thanks a lot !
If you mean the image the controller starts with, try
gallery.startingIndex = 1; // or whatever number

Resources