frangulyan

1

votes
2

answer
401

views

Determine UICollectionView cell height only by autolayout

I need a collection view which displays cells in a grid. So a standard flow layout is fine for me. However, I want to tell how many cells to show per row, while the cell height should be determined by the autolayout constraints that I put on the cell. Here is my cell layout: It is quite simple - an...
frangulyan
1

votes
1

answer
154

views

iOS8 UISplitViewController to always open primary controller on swipe gesture

Is there a way in iOS8 to configure the UISplitViewController to always open the primary (master) controller when a swipe gesture is performed? Currently, if the detail controller is a navigation with some controllers already on stack then swiping (and also using displayModeButtonItem) will go to th...
frangulyan
1

votes
1

answer
885

views

NSURLSession's dataTaskWithRequest: returns nil

I've got a really strange error. I have the following line in code: NSURLSessionDataTask *task = [self.session dataTaskWithRequest:request]; after execution of which the task is nil! This case is not documented anywhere and I couldn't find any similar cases on the web. The session is not nil. This h...
frangulyan
1

votes
1

answer
338

views

Swift passing protocol variable to generic function

Can someone explain why is passing protocol var to a generic function an error in Swift? protocol P {} func f(_: T) {} func g(x: P) { f(x) } // Error This, however, is not an error: protocol P {} func f(_: P) {} func g(x: P) { f(x) } I was just wondering what is the difference of the code generated...
frangulyan
1

votes
1

answer
323

views

Android: at what point is the activity completely loaded and presenting itself?

I want quite simple thing - to know when is my activity completely loaded and presenting itself on the screen - that is when I want a piece of code to run. That piece of code starts by taking a screenshot and running some animations on it. I wrote that code in onResume() and everything is fine durin...
frangulyan
1

votes
2

answer
243

views

iOS Autolayout constraint between non-siblings

Is there a way to define a horizontal distance constraint between two views which are not siblings? I tried to add a constraint to their first common superview but the constraint doesn't seem to work. The Apple documentation says: The constraint may only reference the view itself or its subviews. Bu...
frangulyan
1

votes
1

answer
471

views

Overriding computed property with stored one

Suppose I have a classes A and B like this: class A { var x: Int { return 9 } func p() { print(x) } } class B: A { ... } let v: A = B() v.p() And then I override x in B in three different ways: class B: A { // OPTION 1: FINE - prints 10 override var x: Int { return 10 } // OPTION 2: ERROR - cannot...
frangulyan
6

votes
2

answer
1.8k

views

Change the text colors of all UITableViewCells using UIAppearance

I am not able to change the text colors of a UITableViewCell using UIAppearance mechanism. Here is my code with comments showing what is working for me and what is not: UITableViewCell *cell = [UITableViewCell appearance]; cell.backgroundColor = [UIColor blueColor]; // working cell.textLabel.textCol...
frangulyan
2

votes
1

answer
58

views

Objective-C property name mapping

I wonder if there is an easy and fast way to map a property name from adopted protocol to the property which already comes from a base class? Suppose the example: @protocol Proto @property (nonatomic, readonly, strong) NSString *objectId; @end ... @interface MyBase : NSObject @property (nonatomic,...
frangulyan
2

votes
2

answer
984

views

Android fragment exists from previous state and cannot be removed

I have the following setup which is quite common: in landscape mode I have 2 fragments - A and B. In portrait mode I have only fragment A. I tried to detect if I am in second setup mode by just a simple check: getSupportFragmentManager().findFragmentById(R.id.frag_b) == null This was working fine un...
frangulyan
1

votes
1

answer
378

views

iOS view/controller lifecycle callback on screen unlock or app switch

Is there any function which is get called on view or controller when the user unlocks the phone or comes back to the app? Registering for notifications on app coming to foreground seems to be hacky for me, so I expected something like viewDidLoad or viewDidAppear to be called, but they aren't. My vi...
frangulyan
5

votes
2

answer
4.4k

views

iOS: AVPlayer - getting a snapshot of the current frame of a video

I have spent the whole day and went through a lot of SO answers, Apple references, documentations, etc, but no success. I want a simple thing: I am playing a video using AVPlayer and I want to pause it and get the current frame as UIImage. That's it. My video is a m3u8 file located on the internet,...
frangulyan
1

votes
1

answer
2.2k

views

android:animateLayoutChanges not working in RecyclerView when changing maxLines of TextView

I have a simple setup: a RecyclerView shows a list of items, each containing several TextViews. One of the text views can have multiple lines, initially I have android:maxLines set to 1. In item's click listener I am toggling it between max 1 lines and max infinite (to show full content). It works f...
frangulyan
2

votes
1

answer
384

views

CAShapeLayer draw partially through path end points

When I use CAShapeLayer and create a rectangle shape then the path starts at rectangle's origin (top-left corner) and draws clockwise. Now if I want to draw only part of the shape then I'm using strokeStart and strokeEnd properties. The problem comes when I want to draw a part consisting the path's...
frangulyan
2

votes
0

answer
168

views

iOS: drawViewHierarchyInRect:afterScreenUpdates: doesn't draw a AVPlayerLayer content

I tried to take a snapshot of a UIView which contains an AVPlayerLayer, however the video part was drawn black. On the other hand, when I use resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets: then the resulting view contains the video snapshot correctly. However, I cannot get an image...
frangulyan
5

votes
0

answer
1.7k

views

Autolayout inside UIBarButtonItem's custom view

I am having a strange problem with UIBarButtonItem. I am creating one with a custom view, and the view is of my own MyCustomView type. It contains couple of labels and some other subviews. Whenever I use autolayout in this custom view class to lay out the subviews - the button is displayed on top-le...
frangulyan
2

votes
3

answer
559

views

iOS Change color of label affected by UIVibrancyEffect

Is there a way to somehow affect the color of a label which is under vibrancy effect or at least bring some contrast by setting some tint/alpha/background/whatever properties? As you can see below, in my case the vibrancy created almost unreadable text...
frangulyan
2

votes
4

answer
408

views

iOS: pass gesture to views underneath

I have a simple setup: there are 2 sibling UIViews A and B, B fully covers A (but it is transparent, so A is visible): ┌──────────────────┐ │ View A │ │ │ │ ┌──────────────┴───┐ │...
frangulyan
2

votes
1

answer
96

views

Android - will saving in onPause() cover saving in onSaveInstanceState()?

While being in the beginning phase of my app development, I was using onSaveInstanceState() to save my data in Bundle and restore my state in onCreate() in Activity - this helps quick testing during rotation, for instance. Then I decided that some of my data, lets say just an integer, should be pers...
frangulyan
2

votes
2

answer
304

views

Extract associated value from enum regardless of the case in Swift

I want to get the associated value of swift enum object, is there a way to do it shorter/better than in switch statement below? enum Test { case a(Int), b(Int), c(Int) } func printValue(_ t: Test) { switch t { case .a(let v), .b(let v), .c(let v): print('value \(v)') } }
frangulyan
5

votes
3

answer
862

views

Check whether Swift object is an instance of a given metatype

I need to keep a collection of Swift metatypes and write a function which will check if a given object is an instance of one of them. I can do that easily in Java: Class c = x.getClass(); c.isInstance(someObj) However, I have no idea how to do that in Swift: var isInt = 7 is Int.Type // compiles let...
frangulyan
3

votes
1

answer
293

views

Android-Volley: Set retry policy on ImageLoader

I'm using Volley as network library on Android. I ran into 'limited functionality' problems when using ImageLoader. It seems to be quite useful class with caching and stuff, so I want to continue using it. However, it doesn't give any access to the Request objects it creates. As a result, I'm not ab...
frangulyan
1

votes
1

answer
345

views

Swift json decoding loses json object key order

I have a simple JSON object: { 'values': { 'a':'', 'b':'', 'c':'', 'd':'', 'e':'' } } and I want to decode it to a Swift struct in such a way, that I can later be able to iterate over the keys in values in the exact same order as I receive the JSON object. Is this possible in Swift? My try below: le...
frangulyan
4

votes
1

answer
1.3k

views

AVPlayer plays video composition result incorrectly

I need a simple thing: play a video while rotating and applying CIFilter on it. First, I create the player item: AVPlayerItem *item = [AVPlayerItem playerItemWithURL:videoURL]; // DEBUG LOGGING AVAssetTrack *track = [[item.asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; NSLog(@'Natural...
frangulyan
2

votes
1

answer
338

views

iOS 11 search bar animation bug

I have a search controller attached to a navigation item with a customized search bar styling (colors). Here is the code: searchController = UISearchController(searchResultsController: nil) searchController.searchResultsUpdater = self searchController.hidesNavigationBarDuringPresentation = false sea...
frangulyan
4

votes
3

answer
4.5k

views

Adding detailed text in QMessageBox makes close (X) button disabled

I noticed an interesting thing - if I add a detailed text to QMessageBox (which adds 'Show Details...' button) then executing it will show the system frame's close (X) button disabled and hence marking this window as non-closable (right click on frame -> Close disabled). Here is some sample code: QM...
frangulyan
2

votes
1

answer
448

views

Image rounded corners issue with object-fit: contain

I want to show an image with rounded corners. So the image must stretch to the container but doesn't crop any part, like object-fit: contain. However, border-radius applies to image element, not the picture content. Here is an example (also JSFiddle): body { width: 100vw; height: 100vh; margin: 0...
frangulyan
3

votes
1

answer
3.3k

views

QNetworkReply::UnknownNetworkError from QNetworkAccessManager::get when requesting https with a password protected proxy server

I'm having a problem with QNetworkAccessManager. Here is some brief description of what I am doing: QNetworkAccessManager* manager = new QNetworkAccessManager(this); manager->setProxy(proxy); QUrl url('https://www.example.com'); QNetworkRequest request(url); manager->get(request); In order to test t...
frangulyan
2

votes
0

answer
202

views

UIAppearance for custom controller

I have a custom view controller, say MyViewController. It has a color property which should be changed using UIAppearance mechanism. I did what the documentation is telling to do - marked the property as UI_APPEARANCE_SELECTOR. The controller conforms to UIAppearance and UIAppearanceContainer. When...
frangulyan
7

votes
3

answer
3.4k

views

Swift Generics: Cannot convert value of type to expected argument type

Here is my code: protocol SomeProtocol { } class A: SomeProtocol { } func f1(ofType: T.Type, listener: (T?) -> Void) { } func f2(ofType: T.Type, listener: ([T]?) -> Void) { } func g() { let l1: (SomeProtocol?) -> Void = ... let l2: ([SomeProtocol]?) -> Void = ... f1(ofType: A.self, listener: l1) //...
frangulyan
6

votes
2

answer
912

views

Android: enable/disable app widgets programmatically

Question: Is there a way to enable some of the homescreen widgets that I give out with my app programmatically? For example, having a 'premium' widget and giving access to it only after payment? As the Android docs say, one should add a broadcast receiver in the manifest to tell the system that ther...
frangulyan
4

votes
2

answer
710

views

RenderScript blocking function invokation

I am new to RenderScript and still have not so good idea on blocking/non-blocking nature of the calls from Java layer. The general question is: which situations block the code and allow RenderScript to finish. Particularly: From Java I invoked a kernel using forEach_kernel() and that was not blockin...
frangulyan