I'm looking for a simple way of adding a refresh mechanism to my UIWebView. I've seen posts about the EGO pull to refresh but, to be honest, I don't understand how that works, especially since I have no clue on how to use it with a UIWebView instead of a table view. And it seems to me like a lot of overhead for just a simple refresh.
I thought about adding a navbar but instead of a back button, add a custom "refresh" one. But based on what I've found so far, it seems as complicated as the other solution.
So, basically, I'd like to know what you would do. Keep in mind that the only requirement is that the user have some easy way of refreshing the view. Any suggestion ?
*I'm a begginer in Objective-C so that is why I don't understand how to plug the EGO framework with a UIWebView even after downloading and running the code.
Well,
Create a button and inside button's IBAction,
- (IBAction) performReload:(id) sender {
[self.uiwebview reload];
}
Check the documentation, it will help you a lot at your beginning stage.
Visual Suggestion:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
Related
Generally, when editing text in a text field/input/area/editor, pressing ⌘A will select all of the current text in said field/input/area/editor. I've subclassed NSTextField and NSTextFieldCell, and no matter what I try, I can't seem to get basic "Select All" functionality working. I've tried implementing delegate protocols, intercepting events, manipulating commands made by selectors, and every other thing I can think of. What gives? (I can already hear the "Ever heard of Google?" refrains because of how simple this probably is, but I haven't found a single answer out there. I guess I can thank iOS for that.)
And before I forget to mention it, I also dragged a standard NSTextField into my nib to see if a non-subclassed NSTextField implements Select All behavior by default, and to my shock, it doesn't. Am I going crazy here, or am I completely overlooking something? Isn't Select All almost a requirement when implementing a text field? Apple's First Responder proxy handles everything under the sun (including two versions of selectAll (selectAll and selectAll:), but the n00b is strong with me, and I can't seem to make sense of any of this.
Any help/ideas would be immensely appreciated. Cheers!
The application menu handles sending the keyboard shortcut actions to the application's current first responder. The missing connection would explain why your regular NSTextField objects are missing this functionality as well.
I'm trying to use that MGSplitViewController (already mentioned here, but some one told me I have to ask a new question...), because some ideas will have one or more splitviews and Apple's reviews are not that easy to pass, so I thought I just use some time to test some existing frameworks, like the MGSplitViewController.
But I don't get it working for about 4 long and hard days(and some nights, too ;) ) - any help would really be really great!!!
My problem is the following:
I have just a simple start view with a segmented control. after the launch and some checks I would like to load the splitview in that simple view. I'm using the storyboard for the simple view and I added the xibs from the example (because I had no idea how to integrate them in the storyboard as well - seems to be the next topic, I'll take a look at...)
Sounds very easy, but with the commented header file and the demo project I'm absolutely not able to reproduce it for a non root controller loading...
I have packed the source code for better understanding, downloadable at
http://www.file-upload.net/download-3866273/mgsplittest.zip.html
.
If any one can help me with this, correcting the project, this would be really, really, really great!!!
Greetings,
matthew
I have solved the issue -
FORGET MGSplitViewController :)
Write it your own, really not difficulty:
need two views(navigation_left_sided, detailsview_right_sided) in the YOURSPLITVIEWController in the storyboard
all detailviews should be build with xibs, in storyboard I have not found a way doing this in a clean way (any tipps appreciated)
the leftsided view delegates calls/view loadings to the other
load your detailview controller and display
finished ;)
It is also a good training to work with delegates, observer and asynchronous dispatching. At the time I asked the question, I have not worked much with them - blame on me ;)
Advantage of writting your own:
- reusable
- fully customizable
- in portrait mode also visible, you can just change the sizes of both
- custom animations for changing the detailsview (move details from bottom to top or curl or anything)
- after this you have a lot of basic knowledge like delegates, etc... (it was in my case)
Or use the iOS6 feature for grids also very simple, but iOS6 based devices only...
That's it, very easy :)
Any questions? Just ask :D
But I have written the code for my company, so I cannot share, just answering questions and giving you the tipps from above ;)
Greetings,
matthias
I have seen a lot of different ways of implementing custom cells in a table view.
Like different file owners, get it from bundle and call the the latest obj of the array and a lot more.
But all did not feel right.
What is the best and correct way to create and use custom table view cells (with interface builder).
I think Storyboards are the new proper way. I use this method:
http://iphonedevelopment.blogspot.com/2009/09/table-view-cells-in-interface-builder.html
And it works quite well. I think it's somewhat proper in that you are asking the OS to do most of the work, although it's a little sneaky that the cell is assigned to a property as part of the NIB loading as a side effect.
Had the same problem. For me it is now solved with storyboards in ios5.
I'm trying to learn objective-c by making a GUI application using Xcode 3. I'm wondering if it is possible to change the text of a button outside of a tab view depending on which tab in the tabview is selected? As I said I am trying to learn objective-c so please act as though I know next to nothing in your answer. I should probably mention that I tried making a NSObject and tried to define an IBAction in a .h and .m file but that didn't seem to work. (I have tried setting some breakpoints in those files none of which were ever reached leading me to think something isn't wired the way think it is.)
Sorry for the long winded explanation.
Thanks for all the help!
I actually figured it out. What I needed was object delegation, this page, and of course Google to help get the correct syntax for the actual implementation.
I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help?
Generally, the way you implement it is simply to add the required function to your view's controller, and set its delegate. For example, if you want code to run when the view loads, you just delegate your view to the controller, and implement the awakeFromNib function.
So, to detect a key press in a text view, make sure your controller is the text view's delegate, and then implement this:
- (void)keyUp:(NSEvent *)theEvent
Note that this is an inherited NSResponder method, not a NSTextView method.
Just a tip for syntax highlighting:
Don't highlight the whole text view at once - it's very slow. Also don't highlight the last edited text using -editedRange - it's very slow too if the user pastes a large body of text into the text view.
Instead you need to highlight the visible text which is done like this:
NSRect visibleRect = [[[textView enclosingScrollView] contentView] documentVisibleRect];
NSRange visibleRange = [[textView layoutManager] glyphRangeForBoundingRect:visibleRect inTextContainer:[textView textContainer]];
Then you feed visibleRange to your highlighting code.
It's important to tell us what you're really trying to accomplish — the higher-level goal that you think capturing key events in an NSTextView will address.
For example, when someone asks me how to capture key events in an NSTextField what they really want to know is how to validate input in the field. That's done by setting the field's formatter to an instance of NSFormatter (whether one of the formatters included in Cocoa or a custom one), not by processing keystrokes directly.
So given that example, what are you really trying to accomplish?
I've done some hard digging, and I did find an answer to my own question. I'll get at it below, but thanks to the two fellas who replied. I think that Stack Overflow is a fantastic site already--I hope more Mac developers find their way in once the beta is over--this could be a great resource for other developers looking to transition to the platform.
So, I did, as suggested by Danny, find my answer in delegation. What I didn't understand from Danny's post was that there are a set of delegate-enabled methods in the delegating object, and that the delegate must implement said events. And so for a TextView, I was able to find the method textDidChange, which accomplished what I wanted in an even better way than simply capturing key presses would have done. So if I implement this in my controller:
- (void)textDidChange:(NSNotification *)aNotification;
I can respond to the text being edited. There are, of course, other methods available, and I'm excited to play with them, because I know I'll learn a whole lot as I do. Thanks again, guys.