I have a lot of UI elements on my screen, and I have to tweak their appearance to perfection including the frame, text color, background, color, corner radius, etc. Each tiny tweak means that I have to re-compile the code and restart the simulator - and it can take 5-6 seconds per iteration, which is very time consuming (and annoying) when 100's of tweaks have to be made by trial and error. My question is if there are any techniques to instantly update the properties of each UI element WITHOUT having to recompile the code and relaunch the simulator.
One technique I had in mind is to embed a UIWebView which will automatically download a json from a localhost server that contains all the UI elements and their properties. I would have Grunt Server running on my local machine and it would detect any change made to that json file and cause the UIWebView to refresh and download the new json after every edit. There would be a handler in my code which will set the UI element properties to the new values contained in that json. This way I can just have the simulator and a text editor side by the side and I can see how the changes I make in the json impact the appearance of the UI elements instantly.
Perhaps there are other developers out there who have had the same issue and can share how they overcame this annoying problem. I don't like using nib files - so please don't tell me to use nib files :) Even with .xib files, you still have to compile them.
Make a second little viewController subclass with UISliders etc you can set to do various things, rgba for a colour for example, set up a quick and dirty protocol to push these values back to root viewController and redraw element in question, then pop the second view controller modally to tweak stuff (inside a UIPopover on iPad simulator would probably be easiest. This could become a nice reusable 'skinning' class that you use in development, just need a tool item or button to trigger it)
Probably NSLog the values as well so when you finalize something you can hardcode or typedef it in
Related
I need to download and show an image on the Splash of my application. But I don't know if this is possible or a good practice on the splash, even I wanna know if there's a workaround to make this.
Thanks.
LaunchScreen.storyboard (or Xib) is tremendously limited in functionality compared to a regular storyboard. You won't be able to do much on it.
The only possible way is to have a SplashViewController or the name you prefer as first Window's rootViewController. (can be defined in AppDelegate's application(_, didFinishLaunchingWithOptions) or Main interface in General tab of the Application target.
The initial layout of that first SplashViewController should be exactly as your LaunchScreen, trying to avoid a visual jump between them. After that you're free to show whatever you want.
Obviously, if you are going to do network load or any other type of task that delays the launch, it is convenient to show the user something that indicates this work. As far as possible cache so that in future launch the start is as fast and smooth as possible.
As the application loads, I want to make an image load at the same time, for example, a line would elongate form either side as the application loads, and when it has finished, the line would have reached its maximum length. I have seen this in a few websites, like rime arodaky for example, but I want to this for an iOS application. I have searched on Google but couldn't find anything!
Does anyone know how to do this?
The launch process if we REALY simplify it to accommodate your question, can be split into two parts.
The first part you do not have any control over, and during which a launch image is shown.and it ends with a delegate call-back on the application delegate called
applicationDidFinishLaunchingWithOptions
The second part is you might have some application specific behaviour which requires no activity from the user but you app still isn't interactive.
You need to implement such a progress bar yourself. There is no built in support for this in any of the app templates in Xcode.
You can only do what you want during this second phase. But you have absolutely no control over the first phase, except for that static non-animated launch image.
I think you can just add a photo as a launch image, launch image is just an image.Then you can add the animation when your first view controller appears.You can fake it this way.
I am developing an iPhone app, and have come across an issue that leaves me completely perplexed.
In the app, there is a normal UIView, which consists of a UISegmentedControl. This UISegmentedControl is not once called or looked at in the code, in fact, there is no IBOutlet whatsoever, it lives only on the Storyboard.
Every time I load the app on my phone, my segmented control looks like this:
However, to my dismay, after a certain yet to be found out mixture of using the app, putting it in the background, and then using it again, the segmented control turns into this:
I know I don't have much more information to provide as of yet, but it seems hard to give any sort of code when there isn't any to do with the UI of the segment.
What I can say is that my "Use AutoLayout" is switched off.
I hope one of you can provide me more insight on how to fix this, thanks.
I have this problem with performance of my iPad app..
For developing, I use MonoDevelop, which takes care of Garbage collecting. Still my questions are rather generic, I'd say.
OK, I use TabBarController with 5 NavigationControllers. Inside nav controllers there are some controllers, whose views are TableViews or ScrollViews. Next child is always just regular view.
I have a few questions:
1) TableViews never scroll smoothly. I have some alpha transparency, but since I did my graphics in Photoshop and not programmatically, this transparency should not cause much problems. It doesn't matter whether I have few or many results in table.
On the other hand, I have ScrollView which serves same purpose, i.e. to be a table with different layout and buttons have Photoshop generated transparency as well. It works perfectly.
For tables I applied DequeueReusableCell() which works fine (I see that memory usage is not increasing after scrolling). So why would tables scroll so jerky?
2) My app supports rotation. When I scroll table or scrollView and simultaneously tilt the device a bit, I get maybe 1 or 2 FPS. What is the best way to implement rotation? As I understand, ShouldAutorotateToInterfaceOrientation has to be overridden in all controllers in NavigationController chain. Also, I need to add observer in View I want some changes to happen. Do I have to use BeginGeneratingDeviceOrientationNotifications() in all views or is it enough to do it in Main.cs? Maybe this slows it down?
3) After some time app starts getting memory warnings and then crashes eventually. I tried to read logs and run app with Instruments, but can't find the cause of crash.
4) What exactly happens to a View popped from NavigationController stack? I can't reuse it. But could it be that Monotouch (or me) doesn't dispose it correctly?
I have almost same app for iPhone without support for rotation which never crashes. I think I'm doing something wrong with this rotation, but I'm not sure what.
Any help will be appreciated the most. So, thank you in advance.
Regards
1 - transparencies are always a problem. Even if you're not rendering the images in code, the phone still needs to do the compositing of the image, and that may take a lot of time. UITableViews have to calculate the final composite image every time a new cell is displayed, or the table is scrolled, while UIScrollViews can calculate only once, since the image won't change. So be very careful about it, turn the transparency off, and check if performance improves.
2 - You shouldn't need to notify every uiview in your application. Receive the notification in the controllers that you want to update only, like for example if you want to rearrange items in the UIViewControllers view.
3 - you have one (or many) memory leaks. My guess is that MonoTouch probably can't garbage collect UIViews or UIViewControllers, because they're still being linked from somewhere in UIKit, like a UINavigationController
4 - UIViews are not disposed by UIKit until the app gets a memory warning notification.
Like Eduardo said, alpha transparency in Views comes at a price. There are some tools that you can use to identify the bottlenecks discussed in these WWDC 2011 talks from:
https://developer.apple.com/videos/wwdc/2011/
iOS Performance and Power Optimization with Instruments
Understanding UIKit Rendering
In the "Debug" menu of the iOS simulator you can find various debugging tools that will color different regions of the screen indicating where some problematic rendering is taking place. The WWDC 2011 talks show what you can do to fix those problems.
For your memory problems, it is very likely that you have something pointing out to your objects around, so you need to make sure those objects are gone. While we currently are not shipping our new profiler for MonoTouch that can show the source of the problem, I wrote a "poor man's" debug utility that will help you narrow down which objects are alive. It is available here:
http://tirania.org/tmp/HttpDebug.cs
Call HttpDebug.Start () from your application and as you run, connect with a web browser to http://localhost:5000 to get a list of live Objective-C objects surfaced to C#. The tool is not perfect and shows a lot of irrelevant data, but it would at least give you an idea of what is going on.
I am currently working on an iPhone 2.1 application. I am new to Objective C, coming from a Java background.
My application has as a base the Utility Application template available in Xcode with the iPhone SDK. Currently I have some controls, such as an UISlider and text box, in the FlipsideView. The UISlider already has a method which is being called when the value changes, using targets and selectors. However, I would also like to be able to read, from the MainView, the current (or last) value of the UISlider and textbox.
Keep in mind I am new to development on a Mac, and would appreciate any guidance as to where I should look up such information, be it through the use of delegates or perhaps I am missing something obvious in the structure of the template.
UPDATE:
I am taking a look at the structure and have some more details: The UISlider is being created in FlipsideView.m. I noticed that the Done button is created from RootViewController.m and probably I should move the UISlider code over there. I may incorrectly be using the View to keep code that would be more appropiate in a Controller.
Ultimately you should be updating some underlying object with the values from the controller. In general, the slider belongs in the view layer - it's a display element. The action that adjusting the slider produces, however, is a component of the controller and it should fire back into your model to update a value. I highly recommend drawing boxes on a sheet of paper and trying to produce a clean a separation as possible for your application's layers - doing so in this case would produce two views for each "side" of the utility which would, via a controller, relate to a model. Then, the act of moving the slider would "instantly" update the model on the back. The Cocoa Fundamental video on the iPhone developer site demonstrates this to great effect.
I'm in exactly the same situation: first iphone app, new to mac programming, creating a utility, sliders on the flipside.
By following the example and the free tutorial here (http://www.bestechvideos.com/2008/11/13/writing-iphone-app-free-episode) I determined that the sliders and other controls should be declared on the flipsideviewcontroller. (Which leave the view pretty empty - I guess the use of the Nib resource file for the UI leaves the ...View.m class pretty much redundant?)
Wisequark's answer is a bit to general to help me though.
In terms of specifics:
- I can't find that video is there a link?
- Could we see some code showing the Controller-Model code?
- How do I persist the values set on the slider without having to build UI to go in the system settings?
(BTW is an Answer the right place to add to the question?)