Ana sayfa Mobil iOS Swift – Navigation Bara activity Indicator Ekleme

Swift – Navigation Bara activity Indicator Ekleme

6330
781
PAYLAŞ

Merhaba arkadaşlar,

Bugünkü dersimizde Navigation Bara nasıl bir text eşliğinde activity Indicator ekleyebileceğimizi göreceğiz.

Storyboard çok basit olduğu için hızlıca geçeceğim.

Öncelikle bir Single View Application oluşturun, storyboard dosyanızı açın ve ViewControllerı yukarda editor kısmından Emberd In -> Navigation Controller’a tıklayarak bir navigation controller içine alın.

Ardından iki tane button ekleyin ve constraintleri dilediğiniz gibi ayarlayın. Ben butonlarımın title kısımlarını Start ve Stop olarak ayarladım. Daha sonra Assistant Editor yardımıyla Storyboard’dan ViewController’a her button için ayrı action outletleri ekleyin.

Benim storyboard ve ViewController.swift dosyam aşağıdaki gibi görünüyor. Sizinde buna benzer bir görüntüye sahip olmanız gerekir.

Şimdi gelin activityIndicator(yükleme belirteci) için bir sınıf oluşturalım. ActivityIndicator adında yeni bir Swift dosyası oluşturalım ve projemize ekleyelim.

Sonra dosyamızın içine aşağıdaki kodu kopyalayalım.

  1. Singleton oluşturuyoruz, daha detaylı açıklaması mevcut ancak kısaca, bir obje oluşturma ihtiyacı duymadan direk o objeye refer ederek işlemler yapmamızı sağlayan bir yapı. (Yakında singletonlar ve swift ile nasıl yazılacağıyla ilgili detaylı ders geliyor)
  2. activityLabel adında bir UILabel oluşturuyoruz, koordinatlarını genişlik ve yükseklik bilgisini giriyoruz.
  3. activityIndicator adında bir UIActivityIndicatorView oluşturuyoruz, koordinat ve boyutları girerek.
  4. activityView adında boş bir UIView objesi oluşturuyoruz.

Şimdi animasyonumuzu tasarlayabileceğimiz ve başlatabileceğimiz animateActivity adında title, view, ve navigationItem adlarında 3 parametre alan bir metod tanımlayalım.

  1. İlk önce daha önce oluşturduğumuz activityIndicator’ün stilini belirliyoruz. Ardından gene daha önce oluşturduğumuz activityLabel’ın text özelliğini, metodumuza aldığımız title parametresine eşitliyoruz.
  2. .sizeToFit() metoduyla Labelimizin boyutunun verilen title uzunluğuna eşit olmasını sağlıyoruz.
  3. xPoint ve yPoint adında iki sabit oluşturuyoruz. x noktasını view’ımızın çerçevesinin tam ortası olarak ayarken, y noktasını ise metodumuza parametre olarak aldığımız navigationItem’ın erişilebilen çerçevesinin tam orta noktasının y si olarak ayarlıyoruz. widtyForActivity sabitiylede, indicator ve label genişliklerini toplayarak activityView’e eşitliyoruz. (Not: navigationItem Navigation Controllerın yukardaki bar kısmının Swiftteki tanımlaması)
  4. activityIndicator ve activityLabel objelerini activityView’ımıza subview(alt view) olarak ekliyoruz.
  5. Daha sonra navigationItem parametresinin titleView özelliğini oluşturduğumuz activityView objemize eşitliyoruz, ve ardından activityIndicator.startAnimating() diyerek yükleniyor görüntümüzü navigasyon barımızda görüntülemeye başlıyoruz.

Şimdi ise stopAnimating adında gene navigationItem parametresi alan bir metod tanımlayalım. Bu metodumuzun amacı herhangi yükleme işlemimiz sona erdikten sonra, navigasyon barımızdaki yükleniyor ibarelerini ortadan kaldırmaya yarayacak.

Bu metodda ilk önce activityIndicator objemizi .stopAnimating() metodu ile durduruyoruz, ve ardından navigationItem’in titleView özelliğini nil’e eşitleyerek, daha önceden eklediğimiz activityView objesini silmiş oluyoruz.

Şimdi tekrar ViewController dosyamıza gidelim ve activityIndicator adında oluşturduğumuz ActivityIndicator sınıfından bir obje oluşturalım.

Sonra startTapped metodumuzun içersinde oluşturduğumuz objemizin .animateActivity metodunu tetikleyelim. title olarak dilediğimizi gönderebiliyoruz, ne yazdırmak istersek. View olarak self.view yazmamız gerekiyor çünkü activityIndicator’ü göstermek istediğimiz view, ViewController’ın kendi viewı. navigationItem olarakta, ViewControllerımız zaten bir navigation controller içerisinde gömülü olduğu için direk navigationItem diyoruz.

stopTapped metodumuzdada durdurma işlemini gerçekleştirelim:

Şimdi uygulamamızı çalıştıralım ve Start Stop butonlarına basarak nasıl çalıştığını görelim.

Navigation Bar Loading GIF - Find & Share on GIPHY

Bu dersimizinde sonuna geldik, artık dilediğiniz zaman projelerinizde, navigation bar üzerinde de activityIndicator kullanabilirsiniz.

781 YORUMLAR

  1. Have you ever thought about including a little bit more than just
    your articles? I mean, what you say is valuable and everything.
    Nevertheless imagine if you added some great photos or video clips to give your
    posts more, “pop”! Your content is excellent but with pics and video clips, this website could certainly be one of the greatest in its field.
    Superb blog!

  2. May I simply just say what a comfort to find somebody who truly knows what they are discussing over the internet.
    You definitely understand how to bring an issue to light
    and make it important. More and more people must read this and
    understand this side of your story. I can’t believe you are not more popular because you surely
    possess the gift.

  3. Awesome blog you have here but I was wanting to know if you knew of any user discussion forums
    that cover the same topics talked about in this
    article? I’d really like to be a part of community
    where I can get responses from other experienced individuals that share the
    same interest. If you have any suggestions, please let me
    know. Many thanks!

  4. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  5. Hey there! I could have sworn I’ve been to this blog before but after
    checking through some of the post I realized it’s new
    to me. Anyhow, I’m definitely happy I found it and I’ll be bookmarking and checking back often!

  6. Hey! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any please share. Kudos!

  7. Howdy just wanted to give you a quick heads up.
    The text in your article seem to be running
    off the screen in Firefox. I’m not sure if this is a formatting issue
    or something to do with browser compatibility but
    I figured I’d post to let you know. The style and design look great though!
    Hope you get the problem solved soon. Kudos

  8. Hi, i think that i saw you visited my blog thus i came to “return the favor”.I’m trying to find things to improve my website!I suppose its ok to use a few of your ideas!!

  9. Hi, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam remarks?

    If so how do you prevent it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any assistance is very much appreciated.

  10. Hi there! Do you know if they make any plugins to assist with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains. If you know of any please share. Appreciate it!

  11. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set up?
    I’m assuming having a blog like yours would cost a
    pretty penny? I’m not very internet smart so I’m not 100% certain. Any tips or advice would be greatly appreciated.
    Thank you

  12. Greetings! I know this is kinda off topic however I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My website goes over a lot of the same topics as yours and I believe we could greatly benefit from each other. If you are interested feel free to send me an e-mail. I look forward to hearing from you! Wonderful blog by the way!

  13. Thanks for another informative site. Where else could I get that kind of info written in such an ideal way? I have a project that I’m just now working on, and I’ve been on the look out for such information.

  14. Heya i’m for the first time here. I found this board and I find It really useful & it helped me out much.

    I hope to give something back and help others like you aided me.

  15. Just desire to say your article is as amazing. The clearness in your post is just nice and i can assume you are an expert on this subject. Well with your permission let me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the gratifying work.

  16. I have been absent for a while, but now I remember why I used to love this blog. Thank you, I will try and check back more often. How frequently you update your website?

  17. Hi! Someone in my Myspace group shared this website with us so I came to look it over. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Great blog and excellent style and design.

  18. What’s Happening i am new to this, I stumbled upon this I’ve found It positively helpful and it has aided me out loads. I hope to contribute & aid other users like its helped me. Great job.

  19. Hi, Neat post. There’s an issue together with your site in web explorer, may test thisK IE nonetheless is the marketplace leader and a good component to other people will omit your magnificent writing because of this problem.

  20. In this grand scheme of things you actually get an A+ for effort. Where you misplaced me was first in your particulars. You know, they say, the devil is in the details… And it couldn’t be much more accurate here. Having said that, let me say to you just what exactly did work. The text is certainly very persuasive which is possibly why I am making the effort in order to comment. I do not make it a regular habit of doing that. Next, even though I can easily notice the jumps in reasoning you come up with, I am not certain of exactly how you appear to connect the details that make the conclusion. For now I shall subscribe to your issue but hope in the future you connect your facts much better.

  21. You actually make it appear really easy along with your presentation however I to find this matter to be really something which I think I might never understand. It kind of feels too complicated and very vast for me. I am taking a look ahead for your subsequent put up, I?¦ll attempt to get the cling of it!

  22. I simply could not leave your website prior to suggesting that I really enjoyed the standard info a person provide on your guests? Is going to be back regularly to check up on new posts.

  23. I do like the way you have framed this specific difficulty plus it does supply us some fodder for consideration. However, because of just what I have personally seen, I just wish when other feed-back pile on that individuals keep on point and in no way start on a tirade associated with the news du jour. All the same, thank you for this exceptional piece and although I do not necessarily concur with the idea in totality, I value your perspective.

  24. I love your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to create my own blog and would like to know where u got this from. kudos

  25. My coder is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using Movable-type on several websites for about a year and am nervous about switching to another platform. I have heard fantastic things about blogengine.net. Is there a way I can import all my wordpress content into it? Any help would be really appreciated!

  26. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something informative to read?

  27. Pretty nice post. I simply stumbled upon your weblog and wanted to mention that I have truly enjoyed surfing around your blog posts. In any case I will be subscribing on your feed and I am hoping you write again soon!

  28. NEAUVIA,歐洲血統透明質酸,目前遍布於全世界56個國家,行政總部在瑞士,卻是源自於意大利的品牌。採用21世紀先進的技術,提取出前所未有的高純度透明質酸,迅速的在全球攻占市場,卓越的品質,領先的技術和平民的價位,已經逐漸的出現在大眾的視線裡,被越來越的人使用。NEAUVIA以系列分女性專用和男性專用,大中小分子以及唇部專用和私處專用,其中私處專用己經在國內一些比較大的整形機構普遍使用。素材提取無與倫比的純淨,運用嶄新PEG鏈結技術-更安全

  29. Wonderful paintings! This is the kind of information that are meant to be shared across the internet. Disgrace on the seek engines for not positioning this submit higher! Come on over and consult with my site . Thanks =)

  30. Thanks a bunch for sharing this with all people you actually realize what you’re speaking approximately! Bookmarked. Please also talk over with my website =). We may have a link change arrangement among us!

  31. Hi, Neat post. There is a problem together with your site in internet explorer, could check thisK IE nonetheless is the marketplace chief and a big part of other people will leave out your wonderful writing because of this problem.

  32. of course like your web-site but you need to check the spelling on quite a few of your posts. Several of them are rife with spelling issues and I find it very troublesome to tell the truth nevertheless I’ll certainly come back again.

  33. I have learn some just right stuff here. Certainly worth bookmarking for revisiting. I wonder how so much effort you put to make one of these wonderful informative site.

  34. Attractive component of content. I simply stumbled upon your blog and in accession capital to assert that I get in fact loved account your blog posts. Anyway I’ll be subscribing for your augment or even I achievement you get admission to persistently fast.

  35. Pretty great post. I just stumbled upon your blog and wished to mention that I’ve really loved browsing your blog posts. In any case I will be subscribing to your feed and I’m hoping you write again soon!

  36. Thanks for another excellent post. Where else could anybody get that type of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.

  37. I liked as much as you’ll receive performed proper here. The comic strip is tasteful, your authored material stylish. nevertheless, you command get got an nervousness over that you would like be turning in the following. unwell indisputably come further until now once more since exactly the similar nearly very often within case you protect this increase.

  38. Oh my goodness! an incredible article dude. Thank you However I’m experiencing situation with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting identical rss downside? Anybody who is aware of kindly respond. Thnkx

  39. fantastic submit, very informative. I wonder why the opposite experts of this sector do not realize this. You must proceed your writing. I am confident, you have a great readers’ base already!

  40. It’s really a great and helpful piece of information. I’m satisfied that you simply shared this useful info with us. Please keep us informed like this. Thank you for sharing.

  41. I do agree with all the ideas you have presented in your post. They are very convincing and will definitely work. Still, the posts are very short for beginners. Could you please extend them a little from next time? Thanks for the post.

  42. Hello! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

  43. Howdy would you mind letting me know which webhost you’re working with? I’ve loaded your blog in 3 completely different browsers and I must say this blog loads a lot faster then most. Can you recommend a good internet hosting provider at a reasonable price? Many thanks, I appreciate it!

  44. Nice read, I just passed this onto a friend who was doing some research on that. And he just bought me lunch because I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  45. Thank you for any other informative site. The place else could I am getting that type of information written in such an ideal means? I have a project that I’m just now running on, and I’ve been at the glance out for such information.

  46. I was just seeking this info for some time. After 6 hours of continuous Googleing, finally I got it in your web site. I wonder what is the lack of Google strategy that do not rank this kind of informative sites in top of the list. Usually the top web sites are full of garbage.

  47. It is perfect time to make a few plans for the long run and it is time to be happy. I’ve read this put up and if I may I want to counsel you some fascinating things or tips. Maybe you could write next articles relating to this article. I desire to read even more issues approximately it!

  48. Nice post. I learn one thing more difficult on different blogs everyday. It’s going to all the time be stimulating to learn content from different writers and follow a little bit one thing from their store. I’d choose to use some with the content on my weblog whether you don’t mind. Natually I’ll provide you with a hyperlink in your net blog. Thanks for sharing.

  49. Usually I do not read article on blogs, but I would like to say that this write-up very compelled me to try and do it! Your writing style has been amazed me. Thanks, very nice post.|

  50. I do agree with all the ideas you have presented on your post. They are very convincing and will certainly work. Still, the posts are very quick for beginners. Could you please extend them a little from next time? Thank you for the post.

  51. Thank you for sharing excellent informations. Your web site is very cool. I am impressed by the details that you have on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found simply the info I already searched all over the place and simply could not come across. What a perfect site.

  52. Thanks for sharing excellent informations. Your site is very cool. I am impressed by the details that you have on this website. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles. You, my pal, ROCK! I found just the information I already searched all over the place and just couldn’t come across. What a perfect web-site.

  53. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

  54. What¦s Happening i’m new to this, I stumbled upon this I have found It absolutely useful and it has aided me out loads. I hope to give a contribution & aid different users like its aided me. Good job.

  55. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but other than that, this is wonderful blog. A fantastic read. I’ll definitely be back.

  56. Have you ever considered about including a little bit more than just your articles? I mean, what you say is important and everything. But just imagine if you added some great pictures or videos to give your posts more, “pop”! Your content is excellent but with pics and video clips, this website could undeniably be one of the greatest in its niche. Excellent blog!

  57. Hi there! This post could not be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this post to him. Fairly certain he will have a good read. Thank you for sharing!

  58. I cling on to listening to the news update lecture about receiving free online grant applications so I have been looking around for the best site to get one. Could you advise me please, where could i acquire some?

  59. Great goods from you, man. I’ve understand your stuff previous to and you’re just extremely excellent. I really like what you have acquired here, really like what you’re saying and the way in which you say it. You make it enjoyable and you still take care of to keep it sensible. I cant wait to read far more from you. This is actually a tremendous website.

  60. Normally I don’t read post on blogs, but I wish to say that this write-up very pressured me to try and do so! Your writing taste has been surprised me. Thank you, quite nice article.

  61. Thanks for all your valuable effort on this blog. Kate delights in engaging in internet research and it is simple to grasp why. I learn all concerning the dynamic form you make insightful thoughts by means of your web blog and welcome contribution from other individuals on this article and our own child is really understanding a whole lot. Have fun with the rest of the year. You have been performing a great job.

  62. I have been surfing online greater than 3 hours today, yet I never found any interesting article like yours. It is pretty price sufficient for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will probably be a lot more helpful than ever before. “When you are content to be simply yourself and don’t compare or compete, everybody will respect you.” by Lao Tzu.

  63. That is the fitting blog for anyone who desires to seek out out about this topic. You notice a lot its nearly onerous to argue with you (not that I truly would need…HaHa). You definitely put a brand new spin on a subject thats been written about for years. Nice stuff, simply nice!

  64. Excellent read, I just passed this onto a friend who was doing some research on that. And he just bought me lunch since I found it for him smile So let me rephrase that: Thanks for lunch! “A thing is not necessarily true because a man dies for it.” by Oscar Fingall O’Flahertie Wills Wilde.

  65. I needed to post you one tiny note just to say thanks again for your personal spectacular views you have documented at this time. It was simply remarkably open-handed with you to grant publicly just what numerous people would’ve offered for an e-book to earn some bucks on their own, especially considering the fact that you might well have done it if you wanted. Those secrets additionally worked as a great way to be certain that other people online have similar keenness just like my own to realize good deal more when it comes to this matter. Certainly there are numerous more pleasant times up front for many who scan your site.

  66. Needed to send you this very little observation just to say thanks the moment again for these marvelous pointers you have contributed on this page. It is so pretty open-handed of people like you to make extensively all that a few individuals could possibly have advertised as an ebook in order to make some profit for their own end, precisely since you could have tried it if you ever wanted. The guidelines also worked like the easy way to fully grasp some people have the same keenness really like my very own to find out great deal more related to this issue. I know there are several more pleasurable situations up front for individuals that see your website.

  67. Keep up the wonderful piece of work, I read few articles on this internet site and I conceive that your website is very interesting and contains lots of superb information.

  68. I am really impressed with your writing talents and also with the structure in your blog. Is this a paid topic or did you customize it your self? Anyway keep up the nice quality writing, it’s uncommon to see a nice blog like this one today..

  69. An impressive share, I just given this onto a colleague who was doing a bit of analysis on this. And he in actual fact purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love studying extra on this topic. If attainable, as you change into experience, would you mind updating your weblog with extra details? It is extremely useful for me. Large thumb up for this weblog post!

  70. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  71. Heya i am for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you aided me.

  72. I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this increase.

  73. I actually wanted to type a quick remark in order to say thanks to you for all the stunning facts you are writing on this website. My time consuming internet search has now been paid with beneficial know-how to share with my company. I would admit that we readers are rather fortunate to be in a perfect network with very many wonderful people with very helpful tricks. I feel extremely privileged to have come across your web pages and look forward to tons of more brilliant moments reading here. Thanks once again for a lot of things.

  74. Have you ever thought about including a little bit more than just your articles? I mean, what you say is important and all. However imagine if you added some great images or video clips to give your posts more, “pop”! Your content is excellent but with pics and videos, this blog could definitely be one of the best in its niche. Fantastic blog!

  75. Hey there are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you need any html coding expertise to make your own blog? Any help would be really appreciated!

  76. I have been exploring for a bit for any high-quality articles or blog posts on this sort of space . Exploring in Yahoo I finally stumbled upon this web site. Reading this information So i?¦m satisfied to show that I’ve a very good uncanny feeling I found out exactly what I needed. I most indubitably will make certain to do not omit this site and give it a glance regularly.

  77. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

  78. My brother recommended I might like this website. He was once totally right. This submit actually made my day. You cann’t imagine just how much time I had spent for this info! Thanks!

  79. Yesterday, while I was at work, my sister stole my iPad and tested to see if it can survive a thirty foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views. I know this is completely off topic but I had to share it with someone!

  80. Hello again!

    I have gotten an email saying that my original message was not delivered so here goes again. Please confirm receipt.

    As mentioned in my original message, I would like to contribute an article to your blog on how cryptocurrencies are reshaping the adult and more particularly the escort industry. I had a friend who ran an escort agency in the UK and he always had problems with the authorities, banks and even payment processors. I genuinely feel that cryptocurrencies have the potential to liberalise the escort industry and replace the anachronistic banking model which no longer works in today’s modern society.

    You can find the article on my G-Drive:

    https://drive.google.com/drive/folders/13pbNYoRoWLMHnrU1ySnxF6Zq7JMXsSI3?usp=sharing

    Whilst writing this article, I contacted a couple of websites to get some references and one website has even provided me with some images and have given their permission for you to use them. I have included a short bio about myself. I hope your audience enjoys reading my article.

    I can potentially write a couple more articles as and when I get some free time. It is crazy busy at work after all the festivities!

    Have a fab day!

    Regards
    Tony