Post

Replies

Boosts

Views

Activity

Reply to WWDC 2020 swift student challenge
Conditions for applying are given here: https://developer.apple.com/wwdc21/swift-student-challenge/ Applying Build your Swift playground, answer a few written prompts, provide documentation, and submit. To be eligible for the Challenge, you must: Be 13 years of age or older, or the equivalent minimum age in the relevant jurisdiction (for example, 16 years of age in the European Union); Be registered for free with Apple as an Apple developer or be a member of the Apple Developer Program; and Fulfill one of the following requirements: Be enrolled in an accredited academic institution or official homeschool equivalent; Be enrolled in a STEM organization’s educational curriculum; Be enrolled in an Apple Developer Academy; or Have graduated from high school or equivalent within the past 6 months and be awaiting acceptance or have received acceptance to an accredited academic institution. See last condition: Have graduated from high school or equivalent within the past 6 months and be awaiting acceptance or have received acceptance to an accredited academic institution. So, july 2020 graduation does not match. But may be you meet one of the other requirements ?
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Rearrange collection view cells within it's section
Unless I miss something, you want to authorise change only within the same section. So, you should change line 6 as: if (sourceSection == destSection) { With your code, you could move from section 0 to section 1. In the else { }, you could just emit a beep, to let user know something wrong occurred. Or even better, create a counter of mismoves: var counter = 0 In else, increment counter and trigger alert only if count is 3 } else { count += 1 if count = 3 { // display alert count = 0 // Then reset count to 0 } else { // play a beep } } If that solves the problem, don't forget to close the thread by marking correct answer. Otherwise, please give details on errors: I am using following code but It is giving me errors...
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to UITableView duplicates bottom row on animated insert
Could you try to isolate the problem ? What happens when: you comment out lines 6 to 11 and another try: not using beginUpdates (comment out lines 13 and 15) BTW, doc recommends to preferably use  performBatchUpdates(:completion:) method instead (of beginUpdates-endUpdates): Use the performBatchUpdates(:completion:) method instead of this one whenever possible.  (void)insertRow { NSUInteger rowIndex = self.items.count == 0 ? 0 : 1; [self.items insertObject:[NSString stringWithFormat:@"New item %lu", self.items.count + 1] atIndex:rowIndex]; [UIView beginAnimations:@"twisterTableAnimationId" context:nil]; [UIView setAnimationDuration:1.0f]; [CATransaction begin]; [CATransaction setCompletionBlock:^{ NSLog(@"animation complete"); }]; [self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:rowIndex inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; [self.tableView endUpdates]; [CATransaction commit]; [UIView commitAnimations]; CGRect frame = self.tableView.frame; frame.size.height = [self.tableView sizeThatFits:CGSizeMake(frame.size.width, CGFLOAT_MAX)].height; self.preferredContentSize = frame.size; }
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to hello
You cannot change a button behaviour. That's forbidden. But to control brightness:         UIScreen.main.brightness = 0.1 // between 0 and 1
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Refreshing / Reloading Data of Supplementary View (Header & Footer) for Collection View
Here is the problem: line 8 you recreate a label and add it over if there is already an existing one: let headerUILabelText = UILabel() headerUILabelText.textAlignment = .left headerUILabelText.font = UIFont.systemFont(ofSize: 20, weight: .bold) headerUILabelText.numberOfLines = 0 headerUILabelText.text = "Your Roll Number is \(NumberInteger). Your Exam Numbers are \(examNumbers(number: "\(NumberInteger)"))" headerUILabelText.textColor = .darkGray headerUILabelText.lineBreakMode = .byTruncatingTail headerView.addSubview(headerUILabelText) You should either: remove subviews first test if there is already a UILabel and not recreate if so replace existing subview. I have used this extension: extension UIView { class func getAllSubviewsT: UIView(from parentView: UIView) - [T] { return parentView.subviews.flatMap { subView - [T] in var result = getAllSubviews(from: subView) as [T] if let view = subView as? T { result.append(view) } return result } } class func getAllSubviews(from parentView: UIView, types: [UIView.Type]) - [UIView] { return parentView.subviews.flatMap { subView - [UIView] in var result = getAllSubviews(from: subView) as [UIView] for type in types { if subView.classForCoder == type { result.append(subView) return result } } return result } } func getAllSubviewsT: UIView() - [T] { return UIView.getAllSubviews(from: self) as [T] } func getT: UIView(all type: T.Type) - [T] { return UIView.getAllSubviews(from: self) as [T] } func get(all type: UIView.Type) - [UIView] { return UIView.getAllSubviews(from: self) } } And call in your case: let allLabels = self.headerView.get(all: UILabel.self) for sub in allLabels { sub.removeFromSuperview() } And now you can safely add subview: headerView.addSubview(headerUILabelText)
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21